This is an unofficial mirror of Tkinter reference documentation (based on Python 2.7 and Tk 8.5) created by the late John Shipman.
It was last updated in 2013 and is unmaintained. [More info]
tkFileDialog module provides two
different pop-up windows you can use to give the user the
ability to find existing files or create new files.
Intended for cases where the user wants to select an existing file. If the user selects a nonexistent file, a popup will appear informing them that the selected file does not exist.
Intended for cases where the user wants to create a new file or replace an existing file. If the user selects an existing file, a pop-up will appear informing that the file already exists, and asking if they really want to replace it.
The arguments to both functions are the same:
The default file extension, a string starting with
a period (
'.'). If the user's reply
contains a period, this argument has no effect. It
is appended to the user's reply in case there are
For example, if you supply a
defaultextension='.jpg' argument and the
'gojiro', the returned
file name will be
A list of two-element tuples containing file type
names and patterns that will select what appears in
the file listing. In the screen picture below,
note the pull-down menu labeled “Files of
argument you supply will populate this pull-down
is a file type name
(“PNG” in the example) and a pattern
that selects files of a given type
(“(*.png)” in the example).
The path name of the directory to be displayed initially. The default directory is the current working directory.
The file name to be displayed initially in the “File name:” field, if any.
To make the pop-up appear over some window
this argument. The default behavior is that the
pop-up will appear over your application's root
is a string to be displayed as the pop-up
If the user selects a file, the returned value is the complete path name of the selected file. If the user uses thebutton, the function returns an empty string.
Here is an example: