Table Of Contents
RecycleView Data Model¶
New in version 1.10.0.
The data model part of the RecycleView model-view-controller pattern.
It defines the models (classes) that store the data associated with a
RecycleViewBehavior
. Each model (class)
determines how the data is stored and emits requests to the controller
(RecycleViewBehavior
) when the data is
modified.
-
class
kivy.uix.recycleview.datamodel.
RecycleDataModelBehavior
[source]¶ Bases:
builtins.object
RecycleDataModelBehavior
is the base class for the models that describes and provides the data for theRecycleViewBehavior
.Events: - on_data_changed:
Fired when the data changes. The event may dispatch keyword arguments specific to each implementation of the data model. When dispatched, the event and keyword arguments are forwarded to
refresh_from_data()
.
-
attach_recycleview
(rv)[source]¶ Associates a
RecycleViewBehavior
with this data model.
-
detach_recycleview
()[source]¶ Removes the
RecycleViewBehavior
associated with this data model.
-
recycleview
¶ The
RecycleViewBehavior
instance associated with this data model.
-
class
kivy.uix.recycleview.datamodel.
RecycleDataModel
(**kwargs)[source]¶ Bases:
kivy.uix.recycleview.datamodel.RecycleDataModelBehavior
,kivy.event.EventDispatcher
An implementation of
RecycleDataModelBehavior
that keeps the data in a indexable list. Seedata
.When data changes this class currently dispatches on_data_changed with one of the following additional keyword arguments.
- none: no keyword argument
- With no additional argument it means a generic data change.
- removed: a slice or integer
- The value is a slice or integer indicating the indices removed.
- appended: a slice
- The slice in
data
indicating the first and last new items (i.e. the slice pointing to the new items added at the end). - inserted: a integer
- The index in
data
where a new data item was inserted. - modified: a slice
- The slice with the indices where the data has been modified. This currently does not allow changing of size etc.
-
attach_recycleview
(rv)[source]¶ Associates a
RecycleViewBehavior
with this data model.
-
data
¶ Stores the model’s data using a list.
The data for a item at index i can also be accessed with
RecycleDataModel
[i].
-
detach_recycleview
()[source]¶ Removes the
RecycleViewBehavior
associated with this data model.
-
observable_dict
¶ A dictionary instance, which when modified will trigger a data and consequently an on_data_changed dispatch.