Gtk.TreeExpander¶
- Subclasses:
None
Methods¶
- Inherited:
Gtk.Widget (183), GObject.Object (37), Gtk.Accessible (17), Gtk.Buildable (1)
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Gtk.Widget (25), GObject.Object (7), Gtk.Accessible (6), Gtk.Buildable (9)
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
|---|---|---|---|
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/en |
|||
r/w/en |
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class Gtk.TreeExpander(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
Provides an expander for a tree-like list.
It is typically placed as a bottommost child into a
GtkListViewto allow users to expand and collapse children in a list with a [class`Gtk`.TreeListModel].GtkTreeExpanderprovides the common UI elements, gestures and keybindings for this purpose.On top of this, the “listitem.expand”, “listitem.collapse” and “listitem.toggle-expand” actions are provided to allow adding custom UI for managing expanded state.
It is important to mention that you want to set the [property`Gtk`.ListItem:focusable] property to
Falsewhen using this widget, as you want the keyboard focus to be in the treexpander, and not inside the list to make use of the keybindings.The
GtkTreeListModelmust be set to not be passthrough. Then it will provide [class`Gtk`.TreeListRow] items which can be set via [method`Gtk`.TreeExpander.set_list_row] on the expander. The expander will then watch that row item automatically. [method`Gtk`.TreeExpander.set_child] sets the widget that displays the actual row contents.GtkTreeExpandercan be modified with properties such as [property`Gtk`.TreeExpander:indent-for-icon], [property`Gtk`.TreeExpander:indent-for-depth], and [property`Gtk`.TreeExpander:hide-expander] to achieve a different appearance. This can even be done to influence individual rows, for example by binding the [property`Gtk`.TreeExpander:hide-expander] property to the item count of the model of the treelistrow, to hide the expander for rows without children, even if the row is expandable.- Shortcuts and Gestures
GtkTreeExpandersupports the following keyboard shortcuts:<kbd>+</kbd> or <kbd>*</kbd> expands the expander.
<kbd>-</kbd> or <kbd>/</kbd> collapses the expander.
Left and right arrow keys, when combined with <kbd>Shift</kbd> or <kbd>Ctrl</kbd>+<kbd>Shift</kbd>, will expand or collapse, depending on the locale’s text direction.
<kbd>Ctrl</kbd>+<kbd>␣</kbd> toggles the expander state.
The row can also expand on drag gestures.
- Actions
GtkTreeExpanderdefines a set of built-in actions:listitem.expandexpands the expander if it can be expanded.listitem.collapsecollapses the expander.listitem.toggle-expandtries to expand the expander if it was collapsed or collapses it if it was expanded.
- CSS nodes
`` treeexpander ├── [indent]* ├── [expander] ╰── <child> ``
GtkTreeExpanderhas zero or one CSS nodes with the name “expander” that should display the expander icon. The node will be:checkedwhen it is expanded. If the node is not expandable, an “indent” node will be displayed instead.For every level of depth, another “indent” node is prepended.
- Accessibility
Until GTK 4.10,
GtkTreeExpanderused the [enum`Gtk`.AccessibleRole.group] role.Since GTK 4.12,
GtkTreeExpanderuses the [enum`Gtk`.AccessibleRole.button] role. Toggling it will change theGTK_ACCESSIBLE_STATE_EXPANDEDstate.- classmethod new()[source]¶
- Returns:
a new
GtkTreeExpander- Return type:
Creates a new
GtkTreeExpander
- get_child()[source]¶
- Returns:
The child displayed by self
- Return type:
Gtk.WidgetorNone
Gets the child widget displayed by self.
- get_hide_expander()[source]¶
-
Gets whether the TreeExpander should be hidden in a
Gtk.TreeListRow.New in version 4.10.
- get_indent_for_depth()[source]¶
-
TreeExpander indents each level of depth with an additional indent.
New in version 4.10.
- get_indent_for_icon()[source]¶
-
TreeExpander indents the child by the width of an expander-icon if it is not expandable.
New in version 4.6.
- get_item()[source]¶
- Returns:
The item of the row
- Return type:
Forwards the item set on the
GtkTreeListRowthat self is managing.This call is essentially equivalent to calling:
``c gtk_tree_list_row_get_item (gtk_tree_expander_get_list_row (@self)); ``
- get_list_row()[source]¶
- Returns:
The list row displayed by self
- Return type:
Gets the list row managed by self.
- set_child(child)[source]¶
- Parameters:
child (
Gtk.WidgetorNone) – aGtkWidget
Sets the content widget to display.
- set_hide_expander(hide_expander)[source]¶
-
Sets whether the expander icon should be visible in a
Gtk.TreeListRow.New in version 4.10.
- set_indent_for_depth(indent_for_depth)[source]¶
-
Sets if the TreeExpander should indent the child according to its depth.
New in version 4.10.
- set_indent_for_icon(indent_for_icon)[source]¶
- Parameters:
indent_for_icon (
bool) –Trueif the child should be indented without expander. OtherwiseFalse.
Sets if the TreeExpander should indent the child by the width of an expander-icon when it is not expandable.
New in version 4.6.
- set_list_row(list_row)[source]¶
- Parameters:
list_row (
Gtk.TreeListRoworNone) – aGtkTreeListRow
Sets the tree list row that this expander should manage.
Property Details¶
- Gtk.TreeExpander.props.child¶
- Name:
child- Type:
- Default Value:
- Flags:
The child widget with the actual contents.
- Gtk.TreeExpander.props.hide_expander¶
- Name:
hide-expander- Type:
- Default Value:
- Flags:
Whether the expander icon should be hidden in a
Gtk.TreeListRow. Note that this property simply hides the icon. The actions and keybinding (i.e. collapse and expand) are not affected by this property.A common use for this property would be to bind to the number of children in a
Gtk.TreeListRow's model in order to hide the expander when a row has no children.New in version 4.10.
- Gtk.TreeExpander.props.indent_for_depth¶
- Name:
indent-for-depth- Type:
- Default Value:
- Flags:
TreeExpander indents the child according to its depth.
New in version 4.10.
- Gtk.TreeExpander.props.indent_for_icon¶
- Name:
indent-for-icon- Type:
- Default Value:
- Flags:
TreeExpander indents the child by the width of an expander-icon if it is not expandable.
New in version 4.6.
- Gtk.TreeExpander.props.item¶
- Name:
item- Type:
- Default Value:
- Flags:
The item held by this expander’s row.
- Gtk.TreeExpander.props.list_row¶
- Name:
list-row- Type:
- Default Value:
- Flags:
The list row to track for expander state.