open multiple filenames in tkinter and add the filesnames to a list

askopenfilenames returns a string instead of a list, that problem is still open in the issue tracker, and the best solution so far is to use splitlist:

import Tkinter,tkFileDialog

root = Tkinter.Tk()
filez = tkFileDialog.askopenfilenames(parent=root, title="Choose a file")
print root.tk.splitlist(filez)

Python 3 update:

tkFileDialog has been renamed, and now askopenfilenames directly returns a tuple:

import tkinter as tk
import tkinter.filedialog as fd

root = tk.Tk()
filez = fd.askopenfilenames(parent=root, title="Choose a file")

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)