Gtk.Expander¶
- 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 |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
|
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/c/en |
Whether the expander has been opened to reveal the child widget |
||
r/w/c |
Text of the expander’s label |
||
r/w/c/en |
Whether the label widget should fill all available horizontal space |
||
r/w |
A widget to display in place of the usual expander label |
||
r/w/en |
Whether the expander will resize the toplevel window upon expanding and collapsing |
||
d/r/w/en |
Space to put between the label and the child |
||
r/w/c/en |
The text of the label includes XML markup. See |
||
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 |
---|---|---|---|---|
|
|
d/r |
Size of the expander arrow |
|
|
|
d/r |
Spacing around expander arrow |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
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 aGtk.TreeView
.Normally you use an expander as you would use any other descendant of
Gtk.Bin
; you create the child widget and useGtk.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.Expander
but 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 theGtk.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
:<object class="GtkExpander"> <child type="label"> <object class="GtkLabel" id="expander-label"/> </child> <child> <object class="GtkEntry" id="expander-content"/> </child> </object>
- CSS nodes
expander ├── title │ ├── arrow │ ╰── <label widget> ╰── <child>
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:
- 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
orNone
) – 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.
- get_expanded()[source]¶
- Returns:
the current state of the expander
- Return type:
Queries a
Gtk.Expander
and returns its current state. ReturnsTrue
if the child widget is revealed.See
Gtk.Expander.set_expanded
().New in version 2.4.
- get_label()[source]¶
- 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 by
Gtk.Expander.set_label
(). If the label text has not been set the return value will beNone
. This will be the case if you create an empty button withGtk.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.
- get_label_fill()[source]¶
-
Returns whether the label widget will fill all available horizontal space allocated to self.
New in version 2.22.
- get_label_widget()[source]¶
- Returns:
the label widget, or
None
if there is none- Return type:
Gtk.Widget
orNone
Retrieves the label widget for the frame. See
Gtk.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.
- get_spacing()[source]¶
- 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.
- get_use_markup()[source]¶
-
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.
- get_use_underline()[source]¶
- 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, andFalse
if you want the child widget to be hidden.New in version 2.4.
- set_label(label)[source]¶
-
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]¶
-
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
orNone
) – 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.
- set_spacing(spacing)[source]¶
- 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]¶
-
Sets whether the text of the label contains markup in Pango’s text markup language. See
Gtk.Label.set_markup
().New in version 2.4.
- set_use_underline(use_underline)[source]¶
-
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:
Whether the expander has been opened to reveal the child widget
- Gtk.Expander.props.label¶
-
Text of the expander’s label
- Gtk.Expander.props.label_fill¶
- Name:
label-fill
- Type:
- Default Value:
- Flags:
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:
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:
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:
The text of the label includes XML markup. See
Pango.parse_markup
()