:right-sidebar: True TreeListRow =================================================================== .. currentmodule:: gi.repository.Gtk .. class:: TreeListRow(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` ``GtkTreeListRow`` is used by ``GtkTreeListModel`` to represent items. It allows navigating the model as a tree and modify the state of rows. ``GtkTreeListRow`` instances are created by a ``GtkTreeListModel`` only when the :obj:`~gi.repository.Gtk.TreeListModel.props.passthrough` property is not set. There are various support objects that can make use of ``GtkTreeListRow`` objects, such as the :obj:`~gi.repository.Gtk.TreeExpander` widget that allows displaying an icon to expand or collapse a row or :obj:`~gi.repository.Gtk.TreeListRowSorter` that makes it possible to sort trees properly. Methods ------- .. rst-class:: interim-class .. class:: TreeListRow :no-index: .. method:: get_child_row(position: int) -> ~gi.repository.Gtk.TreeListRow | None If ``self`` is not expanded or ``position`` is greater than the number of children, :const:`None` is returned. :param position: position of the child to get .. method:: get_children() -> ~gi.repository.Gio.ListModel | None If the row is expanded, gets the model holding the children of ``self``. This model is the model created by the ``Gtk.TreeListModelCreateModelFunc`` and contains the original items, no matter what value :obj:`~gi.repository.Gtk.TreeListModel.props.passthrough` is set to. .. method:: get_depth() -> int Gets the depth of this row. Rows that correspond to items in the root model have a depth of zero, rows corresponding to items of models of direct children of the root model have a depth of 1 and so on. The depth of a row never changes until the row is removed from its model at which point it will forever return 0. .. method:: get_expanded() -> bool Gets if a row is currently expanded. .. method:: get_item() -> ~gi.repository.GObject.Object | None Gets the item corresponding to this row, .. method:: get_parent() -> ~gi.repository.Gtk.TreeListRow | None Gets the row representing the parent for ``self``. That is the row that would need to be collapsed to make this row disappear. If ``self`` is a row corresponding to the root model, :const:`None` is returned. The value returned by this function never changes until the row is removed from its model at which point it will forever return :const:`None`. .. method:: get_position() -> int Returns the position in the ``GtkTreeListModel`` that ``self`` occupies at the moment. .. method:: is_expandable() -> bool Checks if a row can be expanded. This does not mean that the row is actually expanded, this can be checked with :obj:`~gi.repository.Gtk.TreeListRow.get_expanded`. If a row is expandable never changes until the row is removed from its model at which point it will forever return :const:`False`. .. method:: set_expanded(expanded: bool) -> None Expands or collapses a row. If a row is expanded, the model of calling the ``Gtk.TreeListModelCreateModelFunc`` for the row's item will be inserted after this row. If a row is collapsed, those items will be removed from the model. If the row is not expandable, this function does nothing. :param expanded: :const:`True` if the row should be expanded Properties ---------- .. rst-class:: interim-class .. class:: TreeListRow :no-index: .. attribute:: props.children :type: ~gi.repository.Gio.ListModel The model holding the row's children. .. attribute:: props.depth :type: int The depth in the tree of this row. .. attribute:: props.expandable :type: bool If this row can ever be expanded. .. attribute:: props.expanded :type: bool If this row is currently expanded. .. attribute:: props.item :type: ~gi.repository.GObject.Object The item held in this row.