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[[Object, Any], ListModel | None], user_data: Any = None) TreeListModel#
Creates a new empty
GtkTreeListModeldisplayingrootwith all rows collapsed.- Parameters:
root – The
GListModelto use as rootpassthrough –
Trueto pass through items from the modelsautoexpand –
Trueto set the autoexpand property and expand therootmodelcreate_func – function to call to create the
GListModelfor 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
positionforself's root model.If
positionis greater than the number of children in the root model,Noneis 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, theGListModelfunctions forselfreturn customGtkTreeListRowobjects. You need to callget_itemon 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_rowto get the customGtkTreeListRows.
- get_row(position: int) TreeListRow | None#
Gets the row object for the given row.
If
positionis greater than the number of items inself,Noneis 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
selfis 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 –
Trueto make the model autoexpand its rows
Properties#
- class TreeListModel
-
- props.item_type: GType#
The type of the None singleton.
Added in version 4.8.