The tkFileDialog
module has methods that allow the user to browse and select directories and files. Namely, askdirectory
and askopenfilename
.
Assigning a variable the file path from a user input Python 2.7
-
05-07-2023 - |
Question
I have a rather large script where I have set a few different files with direct paths. An example would be:
path1 = "C:/temp/"
path2 = "C:/users/<username>/My Documents/test.txt"
Essentially, I would like to set these variables to the file and/or folder path based on a user input. Is it possible to make the user browse to a location and then take that input path and place it into a variable?
Thanks
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow