select multiple files using tkinter

Solutions on MaxInterview for select multiple files using tkinter by the best coders in the world

showing results for - "select multiple files using tkinter"
Elva
15 Jun 2016
1import tkinter as tk
2from tkinter import ttk
3from tkinter import filedialog as fd
4from tkinter.messagebox import showinfo
5
6# create the root window
7root = tk.Tk()
8root.title('Tkinter File Dialog')
9root.resizable(False, False)
10root.geometry('300x150')
11
12
13def select_files():
14    filetypes = (
15        ('text files', '*.txt'),
16        ('All files', '*.*')
17    )
18
19    filenames = fd.askopenfilenames(
20        title='Open files',
21        initialdir='/',
22        filetypes=filetypes)
23
24    showinfo(
25        title='Selected Files',
26        message=filenames
27    )
28
29
30# open button
31open_button = ttk.Button(
32    root,
33    text='Open Files',
34    command=select_files
35)
36
37open_button.pack(expand=True)
38
39root.mainloop()Code language: Python (python)
similar questions
queries leading to this page
select multiple files using tkinter