gtk.FileSelection — a dialog used to prompt the user for a file or directory name


class gtk.FileSelection(gtk.Dialog):
def set_filename(filename)
def get_filename()
def complete(pattern)
def show_fileop_buttons()
def hide_fileop_buttons()
def get_selections()
def set_select_multiple(select_multiple)
def get_select_multiple()


+-- gobject.GObject
  +-- gtk.Object
    +-- gtk.Widget
      +-- gtk.Container
        +-- gtk.Bin
          +-- gtk.Window
            +-- gtk.Dialog
              +-- gtk.FileSelection

Implemented Interfaces

gtk.FileSelection implements gtk.Buildable

gtk.FileSelection Properties

gtk.Object Properties

gtk.Widget Properties

gtk.Container Properties

gtk.Window Properties

gtk.Dialog Properties

"filename"Read/WriteThe currently selected filename.
"select-multiple"Read/WriteIf True allow multiple files to be selected.
"show-fileops"Read/WriteIf True display the buttons for creating and manipulating files.

gtk.FileSelection Style Properties

gtk.Widget Style Properties

gtk.Dialog Style Properties


"dir_list"ReadThe gtk.TreeView widget used to display the directories
"file_list"ReadThe gtk.TreeView widget used to display the files.
"selection_entry"ReadThe gtk.Entry widget used to display the current file selection
"selection_text"ReadThe gtk.Label associated with the selection entry.
"main_vbox"ReadThe gtk.VBox widget that holds all the widgets of the gtk.FileSelection dialog.
"ok_button"ReadThe "OK" button.
"cancel_button"ReadThe "Cancel" button.
"history_pulldown"ReadThe gtk.OptionMenu widget that provides the pulldown list of directory paths.
"history_menu"ReadThe gtk.Menu part of the history_pulldown
"fileop_dialog"ReadThe dialog box used to display the gtk.FileSelection. It can be customized by adding or removing widgets from it using the standard gtk.Dialog methods.
"fileop_entry"ReadThe gtk.Entry in the fileops dialog that is created when one of the fileops buttons is clicked.
"fileop_file"ReadThe name of the file to be operated on by the fileops
"fileop_c_dir"ReadThe "New Folder" fileops button.
"fileop_del_file"ReadThe "Delete File" fileops button
"fileop_ren_file"ReadThe "Rename File" fileops button
"button_area"ReadThe fileops gtk.ButtonBox.
"action_area"ReadA gtk.HBox that can be used by the application to add buttons, etc.

gtk.FileSelection Signal Prototypes

gobject.GObject Signal Prototypes

gtk.Object Signal Prototypes

gtk.Widget Signal Prototypes

gtk.Container Signal Prototypes

gtk.Window Signal Prototypes

gtk.Dialog Signal Prototypes



The gtk.FileSelection is deprecated and should not be used in newly-written code.

The gtk.FileSelection should be used to retrieve file or directory names from the user. It will create a new dialog window containing a directory list, and a file list corresponding to the current working directory. The filesystem can be navigated using the directory list or the drop-down history menu. Alternatively, the TAB key can be used to navigate using filename completion - common in text based editors such as emacs and jed.

File selection dialogs are created with a call to the gtk.FileSelection() constructor.

The default filename can be set using the set_filename() method and the selected filename retrieved using the get_filename() method.

Use the complete() method to display files and directories that match a given pattern. This can be used for example, to show only *.txt files, or only files beginning with gtk*.

Simple file operations; create directory, delete file, and rename file, are available from buttons at the top of the dialog. These can be hidden using the hide_fileop_buttons() method and shown again using the show_fileop_buttons() method.



title :

the text to be used as the title of the fileselection dialog.

Returns :

a new fileselection dialog

Creates a new file selection dialog. By default it will contain gtk.TreeViews displaying the application's current working directory, and its file listing. File operation buttons that allow the user to create a directory, delete files and rename files, are also present.



    def set_filename(filename)

filename :

a string to set as the default file name.

The set_filename() method sets a default path for the file requester. If filename includes a directory path, then the fileselection will open with that path as its current working directory.

Note the encoding of filename is the on-disk encoding, which may not be UTF-8.


    def get_filename()

Returns :

currently-selected filename in the on-disk encoding

The get_filename() method returns the selected filename in the on-disk encoding, which may or may not be the same as that used by GTK (UTF-8). If no file is selected then the selected directory path is returned.


    def complete(pattern)

pattern :

a string containing a pattern which may or may not match any filenames in the current directory.

The complete() method will attempt to match pattern to valid filenames or subdirectories in the current directory. If a match can be made, the matched filename will appear in the text entry field of the file selection dialog. If a partial match can be made, the "Files" list will contain those file names which have been partially matched, and the "Directories" list those directories which have been partially matched.


    def show_fileop_buttons()

The show_fileop_buttons() method shows the fileops buttons: "New Folder", "Delete File" and "Rename File".


    def hide_fileop_buttons()

The hide_fileop_buttons() method hides the fileops buttons: "New Folder", "Delete File" and "Rename File".


    def get_selections()

Returns :

a tuple containing the selected files.

The get_selections() method retrieves a tuple containing the file selections the user has made in the file selection dialog. The first file in the list is equivalent to what the get_filename() method would return.


    def set_select_multiple(select_multiple)

select_multiple :

If True the user is allowed to select multiple files in the file list.

The set_select_multiple() method sets the file list selection mode according to the value of select_multiple. If select_multiple is True the user is allowed to select multiple files in the file list. Use the get_selections() method to retrieve the list of selected files.


    def get_select_multiple()

Returns :

True if the user is allowed to select multiple files in the file list

The get_select_multiple() method determines whether the user is allowed to make multiple file selection in the file list. If the get_select_multiple() method returns True the user is allowed to select multiple files in the file list. See the set_select_multiple() method.