Skip to content

Gtk.ListBoxRow

class — extends Widget, Accessible, Actionable, Buildable, ConstraintTarget

The kind of widget that can be added to a GtkListBox.

ListBox will automatically wrap its children in a GtkListboxRow when necessary.

Constructors

new

@classmethod
def new(cls) -> Widget

Creates a new GtkListBoxRow.

Methods

changed

def changed(self) -> None

Marks row as changed, causing any state that depends on this to be updated.

This affects sorting, filtering and headers.

Note that calls to this method must be in sync with the data used for the row functions. For instance, if the list is mirroring some external data set, and two rows changed in the external data set then when you call ListBoxRow.changed on the first row the sort function must only read the new data for the first of the two changed rows, otherwise the resorting of the rows will be wrong.

This generally means that if you don’t fully control the data model you have to duplicate the data that affects the listbox row functions into the row widgets themselves. Another alternative is to call ListBox.invalidate_sort on any model change, but that is more expensive.

get_activatable

def get_activatable(self) -> bool

Gets whether the row is activatable.

get_child

def get_child(self) -> Widget | None

Gets the child widget of row.

get_header

def get_header(self) -> Widget | None

Returns the current header of the row.

This can be used in a ListBoxUpdateHeaderFunc to see if there is a header set already, and if so to update the state of it.

get_index

def get_index(self) -> int

Gets the current index of the row in its GtkListBox container.

get_selectable

def get_selectable(self) -> bool

Gets whether the row can be selected.

is_selected

def is_selected(self) -> bool

Returns whether the child is currently selected in its GtkListBox container.

set_activatable

def set_activatable(self, activatable: bool) -> None

Set whether the row is activatable.

Parameters:

  • activatableTrue to mark the row as activatable

set_child

def set_child(self, child: Widget | None = ...) -> None

Sets the child widget of self.

Parameters:

  • child — the child widget

set_header

def set_header(self, header: Widget | None = ...) -> None

Sets the current header of the row.

This is only allowed to be called from a ListBoxUpdateHeaderFunc. It will replace any existing header in the row, and be shown in front of the row in the listbox.

Parameters:

  • header — the header

set_selectable

def set_selectable(self, selectable: bool) -> None

Set whether the row can be selected.

Parameters:

  • selectableTrue to mark the row as selectable

Virtual methods

do_activate

def do_activate(self) -> None

Properties

activatable

activatable: bool  # read/write

Determines whether the ::row-activated signal will be emitted for this row.

child

child: Widget  # read/write

The child widget.

selectable

selectable: bool  # read/write

Determines whether this row can be selected.

Signals

activate

def on_activate(self) -> None: ...

This is a keybinding signal, which will cause this row to be activated.

If you want to be notified when the user activates a row (by key or not), use the ListBox.row-activated signal on the row’s parent GtkListBox.