The examples shown above are sufficient for many tasks, but you can customize the file dialog display by specifying what kinds of files will be displayed in the file dialogs like this:
filter = "Python source|*.py"
get_file(filter)
With this filter specification, the only files displayed are .py files. The asterisk (*) is a "wild card" standing for "any text". (The filter option does not work on some versions of Linux.)
Here are other examples of filter expressions:
"Text files|*.txt" # show only text files
"All files|*.*"
# show all types of files
"Python and text|*.py;*.txt" # show both kinds
of files
"Python|*.py|Text|*.txt" # choose which kind to list
With the following filter specification, the menu lets you choose one or the other sets of files:
"Python|*.py|Text|*.txt" # choose which kind to list
In all of these filter expressions, what you place before the "|" character will be displayed to the user (and if there is more than one, the user can choose). What goes after the "|" character is a list separated by semicolons of the file types to be displayed.