ListItem#
Superclasses: Object
Subclasses: ColumnViewCell
Used by list widgets to represent items in a ListModel.
GtkListItem objects are managed by the list widget (with its factory)
and cannot be created by applications, but they need to be populated
by application code. This is done by calling set_child.
GtkListItem objects exist in 2 stages:
- The unbound stage where the listitem is not currently connected to
an item in the list. In that case, the
itemproperty is set toNULL.
- The bound stage where the listitem references an item from the list.
The
itemproperty is notNULL.
Methods#
- class ListItem
-
- get_activatable() bool#
Checks if a listitem has been set to be activatable via
set_activatable.
- get_focusable() bool#
Checks if a listitem has been set to be focusable via
set_focusable.Added in version 4.12.
- get_item() Object | None#
Gets the model item that associated with
self.If
selfis unbound, this function returnsNULL.
- get_position() int#
Gets the position in the model that
selfcurrently displays.If
selfis unbound,GTK_INVALID_LIST_POSITIONis returned.
- get_selectable() bool#
Checks if a listitem has been set to be selectable via
set_selectable.Do not confuse this function with
get_selected.
- get_selected() bool#
Checks if the item is displayed as selected.
The selected state is maintained by the list widget and its model and cannot be set otherwise.
- set_accessible_description(description: str) None#
Sets the accessible description for the listitem.
The accessible description may be used by e.g. screen readers.
Added in version 4.12.
- Parameters:
description – the description
- set_accessible_label(label: str) None#
Sets the accessible label for the listitem.
The accessible label may be used by e.g. screen readers.
Added in version 4.12.
- Parameters:
label – the label
- set_activatable(activatable: bool) None#
Sets
selfto be activatable.If an item is activatable, double-clicking on the item, using the Return key or calling
activatewill activate the item. Activating instructs the containing view to handle activation.GtkListViewfor example will be emitting theactivatesignal.By default, listitems are activatable.
- Parameters:
activatable – if the item should be activatable
- set_child(child: Widget | None = None) None#
Sets the child to be used for this listitem.
This function is typically called by applications when setting up a listitem so that the widget can be reused when binding it multiple times.
- Parameters:
child – The listitem’s child or
NULLto unset
- set_focusable(focusable: bool) None#
Sets
selfto be focusable.If an item is focusable, it can be focused using the keyboard. This works similar to
set_focusable.Note that if items are not focusable, the keyboard cannot be used to activate them and selecting only works if one of the listitem’s children is focusable.
By default, listitems are focusable.
Added in version 4.12.
- Parameters:
focusable – if the item should be focusable
- set_selectable(selectable: bool) None#
Sets
selfto be selectable.If an item is selectable, clicking on the item or using the keyboard will try to select or unselect the item. If this succeeds is up to the model to determine, as it is managing the selected state.
Note that this means that making an item non-selectable has no influence on the selected state at all. A non-selectable item may still be selected.
By default, listitems are selectable. When rebinding them to a new item, they will also be reset to be selectable by GTK.
- Parameters:
selectable – if the item should be selectable