gtk.FileSelection
Prev | The gtk Class Reference | Next

## gtk.FileSelection

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

## Synopsis

    class gtk.FileSelection(gtk.Dialog):
        gtk.FileSelection(title=None)
        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()

## Ancestry

    +-- 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/Write | The currently selected filename.
"select-multiple" | Read/Write | If `True` allow multiple files to be selected.
"show-fileops" | Read/Write | If `True` display the buttons for creating and manipulating files.

## gtk.FileSelection Style Properties

gtk.Widget Style Properties

gtk.Dialog Style Properties

## Attributes

"dir_list" | Read | The `gtk.TreeView` widget used to display the directories
"file_list" | Read | The `gtk.TreeView` widget used to display the files.
"selection_entry" | Read | The `gtk.Entry` widget used to display the current file selection
"selection_text" | Read | The `gtk.Label` associated with the selection entry.
"main_vbox" | Read | The `gtk.VBox` widget that holds all the widgets of the `gtk.FileSelection` dialog.
"ok_button" | Read | The "OK" button.
"cancel_button" | Read | The "Cancel" button.
"history_pulldown" | Read | The `gtk.OptionMenu` widget that provides the pulldown list of directory paths.
"history_menu" | Read | The `gtk.Menu` part of the `history_pulldown`
"fileop_dialog" | Read | The 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" | Read | The `gtk.Entry` in the fileops dialog that is created when one of the fileops buttons is clicked.
"fileop_file" | Read | The name of the file to be operated on by the fileops
"fileop_c_dir" | Read | The "New Folder" fileops button.
"fileop_del_file" | Read | The "Delete File" fileops button
"fileop_ren_file" | Read | The "Rename File" fileops button
"button_area" | Read | The fileops `gtk.ButtonBox`.
"action_area" | Read | A `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

## Description

### Note

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.

## Constructor

        gtk.FileSelection(title=None)

`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.

## Methods

### gtk.FileSelection.set_filename

        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.

### gtk.FileSelection.get_filename

        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.

### gtk.FileSelection.complete

        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.

### gtk.FileSelection.show_fileop_buttons

        def show_fileop_buttons()

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

### gtk.FileSelection.hide_fileop_buttons

        def hide_fileop_buttons()

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

### gtk.FileSelection.get_selections

        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.

### gtk.FileSelection.set_select_multiple

        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.

### gtk.FileSelection.get_select_multiple

        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.

Prev | Up | Next
gtk.FileFilter | Home | gtk.Fixed