In this post, we will see how to resolve Select files and folders with Tkinter’s filedialog
Question:
I want to select files and folders withfiledialog
in Tkinter(Python). I try using askdirectory
and askopenfilenames
. But I can’t find a special dialog in documentation.https://docs.python.org/3/library/dialog.html
This is my sample code:
askopenfilenames
and askdirectory
don’t return a list with the files and the folders that I select.Best Answer:
By default, theaskopenfilenames
and askdirectory
functions return only the file paths or directory path respectively, and not both in a single call.askopenfilenames
and askdirectory
both return tuples, which is why we convert them to lists before concatenating them.If you have better answer, please add a comment about this, thank you!
Source: Stackoverflow.com