The FileChooser is an interface which is used by FileChooserButton, FileChooserWidget, and FileChooserDialog and is constructed when those objects are constructed.


The default action of the FileChooser is to provide functionality to open files.


The action value can be set to one of the following; Gtk.FileChooserAction.OPEN, Gtk.FileChooserAction.SAVE, Gtk.FileChooserAction.SELECT_FOLDER, or Gtk.FileChooserAction.CREATE_FOLDER.

By default, the FileChooser allows selection of a single file only. This can be configured with:


The select_multiple can be set to True which allows the user to hold down Control and select the items with the mouse.

Retreival of the selected filename or uniform resource identifier (URI) is done via:

filename = widget.get_filename()
uri = widget.get_uri()

Alternatively, if you have provided the ability for multiple files to be selected, you must use:

filenames = widget.get_filenames()
uris = widget.get_uris()

Another useful function, particular when saving files is to predefine a filename for the file, for example “Unsaved Document”.


To configure whether the button to create new folders is visible, call:


The create_folders option should be set to False if the button is to be hidden.


The common signals of the FileChooser are as follows:

"file-activated" (filechooser)

The "file-activated" signal emits when the user double-clicks a file, or selects a file and presses Enter.


To view an example for this widget, see the FileChooserWidget, :doc`filechooserdialog`, or FileChooserButton examples.