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

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

Attributes

"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

Description

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.