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

Was it helpful?

Solution

The tkFileDialog module has methods that allow the user to browse and select directories and files. Namely, askdirectory and askopenfilename.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top