View a File or Directory Dialog in Python

I am doing a small project in Python and I would like to browse a file or directory to get their path.

I am using Tkinter and I could not find the file browser only:

filename = tkFileDialog.askopenfilename(parent=root,title='Open file to encrypt') 

or just the directory browser:

 dir = tkFileDialog.askdirectory(parent=root, title='Open file to encrypt') 

Is it possible to combine these two? Drop all the answers!

+6
source share
1 answer

No, they cannot be combined. The file browser and directory browser have different interfaces because they perform different tasks.

Most programs handle this by differentiating the task in the File menu. You may have the option "Select file" or "Select folder". This will take you to a file browser or directory browser.

+4
source

Source: https://habr.com/ru/post/916375/


All Articles