Answers for "How to open dialog box to select folder in python"

1

How to open dialog box to select folder in python

>>> from tkinter import Tk, filedialog
>>>
>>> root = Tk() # pointing root to Tk() to use it as Tk() in program.
>>> root.withdraw() # Hides small tkinter window.
''
>>> root.attributes('-topmost', True) # Opened windows will be active. above all windows despite of selection.
''
>>> open_file = filedialog.askdirectory() # Returns opened path as str
>>> print(open_file) 
C:/Users/User/Music
>>>
Posted by: Guest on January-05-2021

Code answers related to "How to open dialog box to select folder in python"

Python Answers by Framework

Browse Popular Code Answers by Language