Reputation: 143
I want to control what files the Tkinter file dialog displays to the user. I only want the user to be able to see text files, instead of seeing all of the different types of files such as Word or PowerPoint documents.
Is there a way to specify the file type within the askopenfilename()
function?
Edit
I tried to use this code
filename=tkFileDialog.askopenfilename(filetypes='txt')
Upvotes: 2
Views: 3944
Reputation: 13362
You can pass a filetypes
argument with (('text files', 'txt'),)
value.
As per your try -
filename = tkFileDialog.askopenfilename(filetypes=(('text files', 'txt'),))
Upvotes: 5