import tkinter as tk
from tkinter import ttk
from tkinter import filedialog as fd
from tkinter.messagebox import showinfo
root = tk.Tk()
root.title('Tkinter File Dialog')
root.resizable(False, False)
root.geometry('300x150')
def select_files():
filetypes = (
('text files', '*.txt'),
('All files', '*.*')
)
filenames = fd.askopenfilenames(
title='Open files',
initialdir='/',
filetypes=filetypes)
showinfo(
title='Selected Files',
message=filenames
)
open_button = ttk.Button(
root,
text='Open Files',
command=select_files
)
open_button.pack(expand=True)
root.mainloop()Code language: Python (python)