Gtk.FileChooserButton

g Atk.ImplementorIface Atk.ImplementorIface Gtk.Widget Gtk.Widget Atk.ImplementorIface->Gtk.Widget GObject.GInterface GObject.GInterface GObject.GInterface->Atk.ImplementorIface Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable Gtk.FileChooser Gtk.FileChooser GObject.GInterface->Gtk.FileChooser Gtk.Orientable Gtk.Orientable GObject.GInterface->Gtk.Orientable GObject.InitiallyUnowned GObject.InitiallyUnowned GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gtk.Box Gtk.Box Gtk.FileChooserButton Gtk.FileChooserButton Gtk.Box->Gtk.FileChooserButton Gtk.Buildable->Gtk.Widget Gtk.Container Gtk.Container Gtk.Container->Gtk.Box Gtk.FileChooser->Gtk.FileChooserButton Gtk.Orientable->Gtk.Box Gtk.Widget->Gtk.Container

Example

../_images/FileChooserButton.png
Subclasses:None

Properties

Inherited:Gtk.Box (3), Gtk.Container (3), Gtk.Widget (39), Gtk.Orientable (1), Gtk.FileChooser (11)
Name Type Flags Short Description
dialog Gtk.FileChooser w/co The file chooser dialog to use.
title str r/w The title of the file chooser dialog.
width-chars int r/w The desired width of the button widget, in characters.

Child Properties

Inherited:Gtk.Box (5)

Style Properties

Inherited:Gtk.Widget (17)

Signals

Inherited:Gtk.Container (4), Gtk.Widget (69), GObject.Object (1), Gtk.FileChooser (5)
Name Short Description
file-set The ::file-set signal is emitted when the user selects a file.

Fields

Inherited:Gtk.Container (4), Gtk.Widget (69), GObject.Object (1), Gtk.FileChooser (5)
Name Type Access Description
parent Gtk.Box r  

Class Details

class Gtk.FileChooserButton(*args, **kwargs)
Bases:Gtk.Box, Gtk.FileChooser
Abstract:No
Structure:Gtk.FileChooserButtonClass

The Gtk.FileChooserButton is a widget that lets the user select a file. It implements the Gtk.FileChooser interface. Visually, it is a file name with a button to bring up a Gtk.FileChooserDialog. The user can then use that dialog to change the file associated with that button. This widget does not support setting the Gtk.FileChooser :select-multiple property to True.

Create a button to let the user select a file in /etc
{
  GtkWidget *button;

  button = gtk_file_chooser_button_new (_("Select a file"),
                                        GTK_FILE_CHOOSER_ACTION_OPEN);
  gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (button),
                                       "/etc");
}

The Gtk.FileChooserButton supports the Gtk.FileChooserActions Gtk.FileChooserAction.OPEN and Gtk.FileChooserAction.SELECT_FOLDER.

The Gtk.FileChooserButton will ellipsize the label, and will thus request little horizontal space. To give the button more space, you should call Gtk.Widget.get_preferred_size(), Gtk.FileChooserButton.set_width_chars(), or pack the button in such a way that other interface elements give space to the widget.

classmethod new(title, action)[source]
Parameters:
Returns:

a new button widget.

Return type:

Gtk.Widget

Creates a new file-selecting button widget.

New in version 2.6.

classmethod new_with_dialog(dialog)[source]
Parameters:dialog (Gtk.Dialog) – the widget to use as dialog
Returns:a new button widget.
Return type:Gtk.Widget

Creates a Gtk.FileChooserButton widget which uses dialog as its file-picking window.

Note that dialog must be a Gtk.Dialog (or subclass) which implements the Gtk.FileChooser interface and must not have Gtk.DialogFlags.DESTROY_WITH_PARENT set.

Also note that the dialog needs to have its confirmative button added with response Gtk.ResponseType.ACCEPT or Gtk.ResponseType.OK in order for the button to take over the file selected in the dialog.

New in version 2.6.

get_focus_on_click()[source]
Returns:True if the button grabs focus when it is clicked with the mouse.
Return type:bool

Returns whether the button grabs focus when it is clicked with the mouse. See Gtk.FileChooserButton.set_focus_on_click().

New in version 2.10.

Deprecated since version 3.20: Use Gtk.Widget.get_focus_on_click() instead

get_title()[source]
Returns:a pointer to the browse dialog’s title.
Return type:str

Retrieves the title of the browse dialog used by self. The returned value should not be modified or freed.

New in version 2.6.

get_width_chars()[source]
Returns:an integer width (in characters) that the button will use to size itself.
Return type:int

Retrieves the width in characters of the self widget’s entry and/or label.

New in version 2.6.

set_focus_on_click(focus_on_click)[source]
Parameters:focus_on_click (bool) – whether the button grabs focus when clicked with the mouse

Sets whether the button will grab focus when it is clicked with the mouse. Making mouse clicks not grab focus is useful in places like toolbars where you don’t want the keyboard focus removed from the main area of the application.

New in version 2.10.

Deprecated since version 3.20: Use Gtk.Widget.set_focus_on_click() instead

set_title(title)[source]
Parameters:title (str) – the new browse dialog title.

Modifies the title of the browse dialog used by self.

New in version 2.6.

set_width_chars(n_chars)[source]
Parameters:n_chars (int) – the new width, in characters.

Sets the width (in characters) that self will use to n_chars.

New in version 2.6.

do_file_set() virtual

Signal Details

Gtk.FileChooserButton.signals.file_set(file_chooser_button)
Signal Name:file-set
Flags:RUN_FIRST
Parameters:file_chooser_button (Gtk.FileChooserButton) – The object which received the signal

The ::file-set signal is emitted when the user selects a file.

Note that this signal is only emitted when the user changes the file.

New in version 2.12.

Property Details

Gtk.FileChooserButton.props.dialog
Name:dialog
Type:Gtk.FileChooser
Default Value:None
Flags:WRITABLE, CONSTRUCT_ONLY

Instance of the Gtk.FileChooserDialog associated with the button.

New in version 2.6.

Gtk.FileChooserButton.props.title
Name:title
Type:str
Default Value:'Select a File'
Flags:READABLE, WRITABLE

Title to put on the Gtk.FileChooserDialog associated with the button.

New in version 2.6.

Gtk.FileChooserButton.props.width_chars
Name:width-chars
Type:int
Default Value:-1
Flags:READABLE, WRITABLE

The width of the entry and label inside the button, in characters.

New in version 2.6.