Gtk.ListItem

g GObject.Object GObject.Object Gtk.ListItem Gtk.ListItem GObject.Object->Gtk.ListItem

Subclasses:

Gtk.ColumnViewCell

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

get_accessible_description ()

get_accessible_label ()

get_activatable ()

get_child ()

get_focusable ()

get_item ()

get_position ()

get_selectable ()

get_selected ()

set_accessible_description (description)

set_accessible_label (label)

set_activatable (activatable)

set_child (child)

set_focusable (focusable)

set_selectable (selectable)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

accessible-description

str

r/w/en

accessible-label

str

r/w/en

activatable

bool

r/w/en

child

Gtk.Widget

r/w/en

focusable

bool

r/w/en

item

GObject.Object

r/en

position

int

r/en

selectable

bool

r/w/en

selected

bool

r/en

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class Gtk.ListItem(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Gtk.ListItemClass

GtkListItem is used by list widgets to represent items in a [iface`Gio`.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 [method`Gtk`.ListItem.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 [property`Gtk`.ListItem:item] property is set to None.

The bound stage where the listitem references an item from the list. The [property`Gtk`.ListItem:item] property is not None.

get_accessible_description()[source]
Returns:

the accessible description

Return type:

str

Gets the accessible description of self.

New in version 4.12.

get_accessible_label()[source]
Returns:

the accessible label

Return type:

str

Gets the accessible label of self.

New in version 4.12.

get_activatable()[source]
Returns:

True if the item is activatable

Return type:

bool

Checks if a list item has been set to be activatable via Gtk.ListItem.set_activatable().

get_child()[source]
Returns:

The child

Return type:

Gtk.Widget or None

Gets the child previously set via Gtk.ListItem.set_child() or None if none was set.

get_focusable()[source]
Returns:

True if the item is focusable

Return type:

bool

Checks if a list item has been set to be focusable via Gtk.ListItem.set_focusable().

New in version 4.12.

get_item()[source]
Returns:

The item displayed

Return type:

GObject.Object or None

Gets the model item that associated with self.

If self is unbound, this function returns None.

get_position()[source]
Returns:

The position of this item

Return type:

int

Gets the position in the model that self currently displays.

If self is unbound, Gtk.INVALID_LIST_POSITION is returned.

get_selectable()[source]
Returns:

True if the item is selectable

Return type:

bool

Checks if a list item has been set to be selectable via Gtk.ListItem.set_selectable().

Do not confuse this function with [method`Gtk`.ListItem.get_selected].

get_selected()[source]
Returns:

True if the item is selected.

Return type:

bool

Checks if the item is displayed as selected.

The selected state is maintained by the liste widget and its model and cannot be set otherwise.

set_accessible_description(description)[source]
Parameters:

description (str) – the description

Sets the accessible description for the list item, which may be used by e.g. screen readers.

New in version 4.12.

set_accessible_label(label)[source]
Parameters:

label (str) – the label

Sets the accessible label for the list item, which may be used by e.g. screen readers.

New in version 4.12.

set_activatable(activatable)[source]
Parameters:

activatable (bool) – if the item should be activatable

Sets self to be activatable.

If an item is activatable, double-clicking on the item, using the Return key or calling Gtk.Widget.activate() will activate the item. Activating instructs the containing view to handle activation. GtkListView for example will be emitting the [signal`Gtk`.ListView::activate] signal.

By default, list items are activatable.

set_child(child)[source]
Parameters:

child (Gtk.Widget or None) – The list item’s child or None to unset

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.

set_focusable(focusable)[source]
Parameters:

focusable (bool) – if the item should be focusable

Sets self to be focusable.

If an item is focusable, it can be focused using the keyboard. This works similar to [method`Gtk`.Widget.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, list items are focusable.

New in version 4.12.

set_selectable(selectable)[source]
Parameters:

selectable (bool) – if the item should be selectable

Sets self to 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, list items are selectable. When rebinding them to a new item, they will also be reset to be selectable by GTK.

Property Details

Gtk.ListItem.props.accessible_description
Name:

accessible-description

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The accessible description to set on the list item.

New in version 4.12.

Gtk.ListItem.props.accessible_label
Name:

accessible-label

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The accessible label to set on the list item.

New in version 4.12.

Gtk.ListItem.props.activatable
Name:

activatable

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

If the item can be activated by the user.

Gtk.ListItem.props.child
Name:

child

Type:

Gtk.Widget

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Widget used for display.

Gtk.ListItem.props.focusable
Name:

focusable

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

If the item can be focused with the keyboard.

New in version 4.12.

Gtk.ListItem.props.item
Name:

item

Type:

GObject.Object

Default Value:

None

Flags:

READABLE, EXPLICIT_NOTIFY

Displayed item.

Gtk.ListItem.props.position
Name:

position

Type:

int

Default Value:

4294967295

Flags:

READABLE, EXPLICIT_NOTIFY

Position of the item.

Gtk.ListItem.props.selectable
Name:

selectable

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

If the item can be selected by the user.

Gtk.ListItem.props.selected
Name:

selected

Type:

bool

Default Value:

False

Flags:

READABLE, EXPLICIT_NOTIFY

If the item is currently selected.