Gtk.TreeExpander¶
- Subclasses:
None
Methods¶
- Inherited:
Gtk.Widget (181), GObject.Object (37), Gtk.Accessible (15), 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:
GtkTreeExpander
is a widget that provides an expander for a list.It is typically placed as a bottommost child into a
GtkListView
to allow users to expand and collapse children in a list with a [class`Gtk`.TreeListModel].GtkTreeExpander
provides 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
False
when 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
GtkTreeListModel
must 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.GtkTreeExpander
can 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.- CSS nodes
`` treeexpander ├── [indent]* ├── [expander] ╰── <child> ``
GtkTreeExpander
has zero or one CSS nodes with the name “expander” that should display the expander icon. The node will be:checked
when 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,
GtkTreeExpander
used theGTK_ACCESSIBLE_ROLE_GROUP
role.Since GTK 4.12,
GtkTreeExpander
uses theGTK_ACCESSIBLE_ROLE_BUTTON
role. Toggling it will change theGTK_ACCESSIBLE_STATE_EXPANDED
state.- 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.Widget
orNone
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
GtkTreeListRow
that 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.Widget
orNone
) – 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
) –True
if 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.TreeListRow
orNone
) – 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.