Gtk.Expander - Classes - Gtk 3.0 (original) (raw)
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 GObject.InitiallyUnowned GObject.InitiallyUnowned GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gtk.Bin Gtk.Bin Gtk.Expander Gtk.Expander Gtk.Bin->Gtk.Expander Gtk.Buildable->Gtk.Widget Gtk.Container Gtk.Container Gtk.Container->Gtk.Bin Gtk.Widget->Gtk.Container
Subclasses:
None
Methods¶
Inherited:
Gtk.Bin (1), Gtk.Container (35), Gtk.Widget (278), GObject.Object (37), Gtk.Buildable (10)
Structs:
Gtk.ContainerClass (5), Gtk.WidgetClass (12), GObject.ObjectClass (5)
class | new (label) |
---|---|
class | new_with_mnemonic (label) |
get_expanded () | |
get_label () | |
get_label_fill () | |
get_label_widget () | |
get_resize_toplevel () | |
get_spacing () | |
get_use_markup () | |
get_use_underline () | |
set_expanded (expanded) | |
set_label (label) | |
set_label_fill (label_fill) | |
set_label_widget (label_widget) | |
set_resize_toplevel (resize_toplevel) | |
set_spacing (spacing) | |
set_use_markup (use_markup) | |
set_use_underline (use_underline) |
Virtual Methods¶
Inherited:
Gtk.Container (10), Gtk.Widget (82), GObject.Object (7), Gtk.Buildable (10)
do_activate () |
---|
Properties¶
Inherited:
Gtk.Container (3), Gtk.Widget (39)
Name | Type | Flags | Short Description |
---|---|---|---|
expanded | bool | r/w/c/en | Whether the expander has been opened to reveal the child widget |
label | str | r/w/c | Text of the expander’s label |
label-fill | bool | r/w/c/en | Whether the label widget should fill all available horizontal space |
label-widget | Gtk.Widget | r/w | A widget to display in place of the usual expander label |
resize-toplevel | bool | r/w/en | Whether the expander will resize the toplevel window upon expanding and collapsing |
spacing | int | d/r/w/en | Space to put between the label and the child deprecated |
use-markup | bool | r/w/c/en | The text of the label includes XML markup. See Pango.parse_markup() |
use-underline | bool | r/w/c/en | If set, an underline in the text indicates the next character should be used for the mnemonic accelerator key |
Style Properties¶
Inherited:
Name | Type | Default | Flags | Short Description |
---|---|---|---|---|
expander-size | int | 10 | d/r | Size of the expander arrow deprecated |
expander-spacing | int | 2 | d/r | Spacing around expander arrow deprecated |
Signals¶
Inherited:
Gtk.Container (4), Gtk.Widget (69), GObject.Object (1)
Name | Short Description |
---|---|
activate |
Fields¶
Inherited:
Gtk.Container (4), Gtk.Widget (69), GObject.Object (1)
Name | Type | Access | Description |
---|---|---|---|
bin | Gtk.Bin | r |
Class Details¶
class Gtk.Expander(**kwargs)¶
Bases:
Abstract:
No
Structure:
A Gtk.Expander allows the user to hide or show its child by clicking on an expander triangle similar to the triangles used in a Gtk.TreeView.
Normally you use an expander as you would use any other descendant of Gtk.Bin; you create the child widget and use Gtk.Container.add() to add it to the expander. When the expander is toggled, it will take care of showing and hiding the child automatically.
Special Usage
There are situations in which you may prefer to show and hide the expanded widget yourself, such as when you want to actually create the widget at expansion time. In this case, create a Gtk.Expanderbut do not add a child to it. The expander widget has anGtk.Expander :expanded property which can be used to monitor its expansion state. You should watch this property with a signal connection as follows:
static void expander_callback (GObject *object, GParamSpec *param_spec, gpointer user_data) { GtkExpander *expander;
expander = GTK_EXPANDER (object);
if (gtk_expander_get_expanded (expander)) { // Show or create widgets } else { // Hide or destroy widgets } }
static void create_expander (void) { GtkWidget *expander = gtk_expander_new_with_mnemonic ("_More Options"); g_signal_connect (expander, "notify::expanded", G_CALLBACK (expander_callback), NULL);
// ... }
The Gtk.Expander implementation of the Gtk.Buildable interface supports placing a child in the label position by specifying “label” as the “type” attribute of a <child>
element. A normal content child can be specified without specifying a <child>
type attribute.
An example of a UI definition fragment with Gtk.Expander:
CSS nodes
expander ├── title │ ├── arrow │ ╰── ╰──
Gtk.Expander has three CSS nodes, the main node with the name expander, a subnode with name title and node below it with name arrow. The arrow of an expander that is showing its child gets the :checked
pseudoclass added to it.
classmethod new(label)[source]¶
Parameters:
label (str or None) – the text of the label
Returns:
a new Gtk.Expander widget.
Return type:
Creates a new expander using label as the text of the label.
New in version 2.4.
classmethod new_with_mnemonic(label)[source]¶
Parameters:
label (str or None) – the text of the label with an underscore in front of the mnemonic character
Returns:
a new Gtk.Expander widget.
Return type:
Creates a new expander using label as the text of the label. If characters in label are preceded by an underscore, they are underlined. If you need a literal underscore character in a label, use “__” (two underscores). The first underlined character represents a keyboard accelerator called a mnemonic. Pressing Alt and that key activates the button.
New in version 2.4.
Returns:
the current state of the expander
Return type:
Queries a Gtk.Expander and returns its current state. Returns Trueif the child widget is revealed.
See Gtk.Expander.set_expanded().
New in version 2.4.
Returns:
The text of the label widget. This string is owned by the widget and must not be modified or freed.
Return type:
Fetches the text from a label widget including any embedded underlines indicating mnemonics and Pango markup, as set byGtk.Expander.set_label(). If the label text has not been set the return value will be None. This will be the case if you create an empty button with Gtk.Button.new() to use as a container.
Note that this function behaved differently in versions prior to 2.14 and used to return the label text stripped of embedded underlines indicating mnemonics and Pango markup. This problem can be avoided by fetching the label text directly from the label widget.
New in version 2.4.
Returns:
True if the label widget will fill all available horizontal space
Return type:
Returns whether the label widget will fill all available horizontal space allocated to self.
New in version 2.22.
Returns:
the label widget, or None if there is none
Return type:
Gtk.Widget or None
Retrieves the label widget for the frame. SeeGtk.Expander.set_label_widget().
New in version 2.4.
get_resize_toplevel()[source]¶
Returns:
the “resize toplevel” setting.
Return type:
Returns whether the expander will resize the toplevel widget containing the expander upon resizing and collpasing.
New in version 3.2.
Returns:
spacing between the expander and child
Return type:
Gets the value set by Gtk.Expander.set_spacing().
New in version 2.4.
Deprecated since version 3.20: Use margins on the child instead.
Returns:
True if the label’s text will be parsed for markup
Return type:
Returns whether the label’s text is interpreted as marked up with the Pango text markup language. See Gtk.Expander.set_use_markup().
New in version 2.4.
Returns:
True if an embedded underline in the expander label indicates the mnemonic accelerator keys
Return type:
Returns whether an embedded underline in the expander label indicates a mnemonic. See Gtk.Expander.set_use_underline().
New in version 2.4.
set_expanded(expanded)[source]¶
Parameters:
expanded (bool) – whether the child widget is revealed
Sets the state of the expander. Set to True, if you want the child widget to be revealed, and False if you want the child widget to be hidden.
New in version 2.4.
Parameters:
label (str or None) – a string
Sets the text of the label of the expander to label.
This will also clear any previously set labels.
New in version 2.4.
set_label_fill(label_fill)[source]¶
Parameters:
label_fill (bool) – True if the label should should fill all available horizontal space
Sets whether the label widget should fill all available horizontal space allocated to self.
Note that this function has no effect since 3.20.
New in version 2.22.
set_label_widget(label_widget)[source]¶
Parameters:
label_widget (Gtk.Widget or None) – the new label widget
Set the label widget for the expander. This is the widget that will appear embedded alongside the expander arrow.
New in version 2.4.
set_resize_toplevel(resize_toplevel)[source]¶
Parameters:
resize_toplevel (bool) – whether to resize the toplevel
Sets whether the expander will resize the toplevel widget containing the expander upon resizing and collpasing.
New in version 3.2.
Parameters:
spacing (int) – distance between the expander and child in pixels
Sets the spacing field of self, which is the number of pixels to place between expander and the child.
New in version 2.4.
Deprecated since version 3.20: Use margins on the child instead.
set_use_markup(use_markup)[source]¶
Parameters:
use_markup (bool) – True if the label’s text should be parsed for markup
Sets whether the text of the label contains markup inPango’s text markup language. See Gtk.Label.set_markup().
New in version 2.4.
set_use_underline(use_underline)[source]¶
Parameters:
use_underline (bool) – True if underlines in the text indicate mnemonics
If true, an underline in the text of the expander label indicates the next character should be used for the mnemonic accelerator key.
New in version 2.4.
do_activate() virtual¶
Keybinding signal is emitted when the user hits the Enter key.
Signal Details¶
Gtk.Expander.signals.activate(expander)¶
Signal Name:
activate
Flags:
Parameters:
expander (Gtk.Expander) – The object which received the signal
Property Details¶
Gtk.Expander.props.expanded¶
Name:
expanded
Type:
Default Value:
Flags:
READABLE, WRITABLE, CONSTRUCT, EXPLICIT_NOTIFY
Whether the expander has been opened to reveal the child widget
Gtk.Expander.props.label¶
Name:
label
Type:
Default Value:
Flags:
Text of the expander’s label
Gtk.Expander.props.label_fill¶
Name:
label-fill
Type:
Default Value:
Flags:
READABLE, WRITABLE, CONSTRUCT, EXPLICIT_NOTIFY
Whether the label widget should fill all available horizontal space.
Note that this property is ignored since 3.20.
Gtk.Expander.props.label_widget¶
Name:
label-widget
Type:
Default Value:
Flags:
A widget to display in place of the usual expander label
Gtk.Expander.props.resize_toplevel¶
Name:
resize-toplevel
Type:
Default Value:
Flags:
READABLE, WRITABLE, EXPLICIT_NOTIFY
When this property is True, the expander will resize the toplevel widget containing the expander upon expanding and collapsing.
New in version 3.2.
Gtk.Expander.props.spacing¶
Name:
spacing
Type:
Default Value:
0
Flags:
DEPRECATED, READABLE, WRITABLE, EXPLICIT_NOTIFY
Space to put between the label and the child when the expander is expanded.
Deprecated since version 3.20: This property is deprecated and ignored. Use margins on the child instead.
Gtk.Expander.props.use_markup¶
Name:
use-markup
Type:
Default Value:
Flags:
READABLE, WRITABLE, CONSTRUCT, EXPLICIT_NOTIFY
The text of the label includes XML markup. See Pango.parse_markup()
Gtk.Expander.props.use_underline¶
Name:
use-underline
Type:
Default Value:
Flags:
READABLE, WRITABLE, CONSTRUCT, EXPLICIT_NOTIFY
If set, an underline in the text indicates the next character should be used for the mnemonic accelerator key