marianydev
marianydev

Reputation: 89

Tkinter FileTypes (askopenfilename), how to add Folder option

How can you add an option so that you can select a folder or directory instead of a file extension type. For example, I want two options, a zip and a folder FileTypes option in my askopenfilename statement. I'd put filetypes=[('Zip File', '*.zip'), for a Zip file but what do I put for an actual directory or folder?

Upvotes: 1

Views: 5563

Answers (1)

mhawke
mhawke

Reputation: 87054

Try filedialog.askdirectory():

from tkinter import filedialog

dirname = filedialog.askdirectory()

For Python 2 use tkFileDialog.askdirectory().

Upvotes: 2

Related Questions