1

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?

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685

1 Answers1

4

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

James Waldby - jwpat7
  • 8,593
  • 2
  • 22
  • 37
  • In python 3, [the API changed](https://stackoverflow.com/a/673309/3077939) a little, so the dialog is now `tkinter.filedialog`. – aluriak Jul 01 '17 at 13:00