Skip to content

Gtk.ColumnViewCell

class — extends ListItem

Represents items in a cell in ColumnView.

The GtkColumnViewCells are managed by the ColumnView widget (with its factory) and cannot be created by applications, but they need to be populated by application code. This is done by calling ColumnViewCell.set_child.

GtkColumnViewCells exist in 2 stages:

  1. The unbound stage where the listitem is not currently connected to an item in the list. In that case, the ColumnViewCell.item property is set to None.

  2. The bound stage where the listitem references an item from the list. The ColumnViewCell.item property is not None.

Methods

get_child

def get_child(self) -> Widget | None

Gets the child previously set via ColumnViewCell.set_child or None if none was set.

get_focusable

def get_focusable(self) -> bool

Checks if a list item has been set to be focusable via ColumnViewCell.set_focusable.

get_item

def get_item(self) -> GObject.Object | None

Gets the model item that associated with self.

If self is unbound, this function returns None.

get_position

def get_position(self) -> int

Gets the position in the model that self currently displays.

If self is unbound, INVALID_LIST_POSITION is returned.

get_selected

def get_selected(self) -> 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_child

def set_child(self, child: Widget | 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 list item's child or None to unset

set_focusable

def set_focusable(self, focusable: bool) -> None

Sets self to be focusable.

If an item is focusable, it can be focused using the keyboard. This works similar to 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.

Parameters:

  • focusable — if the item should be focusable

Properties

child

child: Widget  # read/write

Widget used for display.

focusable

focusable: bool  # read/write

If the item can be focused with the keyboard.

item

item: GObject.Object  # read-only

Displayed item.

position

position: int  # read-only

Position of the item.

selected

selected: bool  # read-only

If the item is currently selected.