TreeListModel#
Superclasses: Object
Implemented Interfaces: ListModel
GtkTreeListModel
is a list model that can create child models on demand.
Constructors#
- class TreeListModel
- classmethod new(root: ListModel, passthrough: bool, autoexpand: bool, create_func: Callable[[...], ListModel | None], *user_data: Any) TreeListModel #
Creates a new empty
GtkTreeListModel
displayingroot
with all rows collapsed.- Parameters:
root – The
GListModel
to use as rootpassthrough –
True
to pass through items from the modelsautoexpand –
True
to set the autoexpand property and expand theroot
modelcreate_func – function to call to create the
GListModel
for the children of an itemuser_data – Data to pass to
create_func
Methods#
- class TreeListModel
- get_autoexpand() bool #
Gets whether the model is set to automatically expand new rows that get added.
This can be either rows added by changes to the underlying models or via
set_expanded
.
- get_child_row(position: int) TreeListRow | None #
Gets the row item corresponding to the child at index
position
forself
’s root model.If
position
is greater than the number of children in the root model,None
is returned.Do not confuse this function with
get_row
.- Parameters:
position – position of the child to get
- get_passthrough() bool #
Gets whether the model is passing through original row items.
If this function returns
False
, theGListModel
functions forself
return customGtkTreeListRow
objects. You need to callget_item
on these objects to get the original item.If
True
, the values of the child models are passed through in their original state. You then need to callget_row
to get the customGtkTreeListRow
’s.
- get_row(position: int) TreeListRow | None #
Gets the row object for the given row.
If
position
is greater than the number of items inself
,None
is returned.The row object can be used to expand and collapse rows as well as to inspect its position in the tree. See its documentation for details.
This row object is persistent and will refer to the current item as long as the row is present in
self
, independent of other rows being added or removed.If
self
is set to not be passthrough, this function is equivalent to callingget_item()
.Do not confuse this function with
get_child_row
.- Parameters:
position – the position of the row to fetch
- set_autoexpand(autoexpand: bool) None #
Sets whether the model should autoexpand.
If set to
True
, the model will recursively expand all rows that get added to the model. This can be either rows added by changes to the underlying models or viaset_expanded
.- Parameters:
autoexpand –
True
to make the model autoexpand its rows
Properties#
- class TreeListModel