ae.kivy_dyn_chi
dynamic children mix-in for kivy container widgets
this ae portion is providing the mixin class DynamicChildrenBehavior
to add children widgets dynamically
and data-driven to your kivy popup widget (like DropDowns, Popups, Menus, Selectors).
Module Attributes
child attribute (value of the 'kwargs' and 'attributes' keys) |
|
item dict value (str for 'cls' key, dict for 'kwargs'/'attributes') |
|
|
|
Classes
|
mixin class for the dynamic creation/refresh of child widgets from a data map. |
- DataItemValueType
item dict value (str for ‘cls’ key, dict for ‘kwargs’/’attributes’)
- DataItemType
DynamicChildrenBehavior.child_data_maps
item type
- ChildrenDataType
- _child_data_dict(child_data, cls, key, defaults)[source]
determine child data dict values and put children default values for the keys not specified in child data.
- class DynamicChildrenBehavior(**kwargs)[source]
Bases:
object
mixin class for the dynamic creation/refresh of child widgets from a data map.
at least one of the classes that is mixing in this class has to inherit from Widget (or EventDispatcher) to get the
child_data_maps
attribute correctly initialized and firing on change.-
child_data_defaults:
List
[Dict
[str
,Union
[str
,Dict
[str
,Any
]]]] child data default values for all the children with the same cls key that are specified via the
ae.kivy_dyn_chi.DynamicChildrenBehavior.child_data_maps
property. if the cls key is missing or its item value is empty then the defaults in the other item values will be used for all children.child_data_defaults
is aListProperty
and defaults to an empty list.
-
child_data_maps:
List
[Dict
[str
,Union
[str
,Dict
[str
,Any
]]]] list of child data dicts to instantiate the children of the inheriting layout/widget.
each child data dict is defining its own widget with the following keys:
cls: either the class name or the class/type object of the widget to be created dynamically.
kwargs: dict of keyword arguments that will be passed to the constructor method of the widget. all values in this dict with the magic string ‘replace_with_data_map_popup’ will be replaced with the instance of the container before it gets passed to the __init__ method of the child (see
deep_replace()
).attributes: dict of attributes where the key is specifying the attribute name/path and the value the finally assigned attribute value. the attribute name (the key of this dict) can be a deep/combined attribute/index path which allows to update deeper objects within the child object (via
key_path_object()
). all values in this dict with the magic string ‘replace_with_data_map_popup’ will be replaced with the instance of the container before the child attributes get updated. all values in this dict with the magic string ‘replace_with_data_map_child’ will be replaced with the instance of the child before they get applied to it (viadeep_replace()
).
child_data_maps
is aListProperty
and defaults to an empty list.
- __init__(**kwargs)[source]
add dynamic creation and refresh of children to this layout (Popup/Dropdown/…) widget.
- refresh_child_data_widgets(*_args, **init_kwargs)[source]
recreate dynamic children of the passed widget.
- Parameters:
_args¶ – not needed extra args (only passed if this function get called as event handler).
init_kwargs¶ – container kwargs (passed from
__init__()
method).
-
child_data_defaults: