gtk.FileSelection
gtk.FileSelection — a dialog used to prompt the user for a file or directory name
Synopsis
class gtk.FileSelection(gtk.Dialog): |
Ancestry
+--gobject.GObject +-- gtk.Object +-- gtk.Widget +-- gtk.Container +-- gtk.Bin +-- gtk.Window +-- gtk.Dialog +-- gtk.FileSelection
gtk.FileSelection Properties
|
Attributes
|
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)
| 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
)
| 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
)
| 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
)
| 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.