Reputation: 89
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
Reputation: 87054
Try filedialog.askdirectory()
:
from tkinter import filedialog
dirname = filedialog.askdirectory()
For Python 2 use tkFileDialog.askdirectory()
.
Upvotes: 2