user1361953
user1361953

Reputation: 11

How to use a file dialog in tkinter to get a filename?

I am writing a small program to enter a file name in an entry dialog in python tkinter. The code currently using a entry dialog which lets me put in a file name manually. However, I wish to use the file browser kind of feature in place of manual typing in of the file. To add on, I wish to not open the file in the dialog itself but rather store the entire path to a variable. Is it possible to do so?

Upvotes: 1

Views: 513

Answers (1)

James Waldby - jwpat7
James Waldby - jwpat7

Reputation: 8711

Use tkFileDialog.askopenfilename(), as described in a tkinter.unpythonic.net webpage.

askopenfilename(**options) gets a name or names and has options defaultextension, filetypes, initialdir, initialfile, multiple, message, parent, title

Upvotes: 4

Related Questions