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

AttrMapType

child attribute (value of the 'kwargs' and 'attributes' keys)

DataItemValueType

item dict value (str for 'cls' key, dict for 'kwargs'/'attributes')

DataItemType

DynamicChildrenBehavior.child_data_maps item type

ChildrenDataType

DynamicChildrenBehavior.child_data_maps type

Classes

DynamicChildrenBehavior(**kwargs)

mixin class for the dynamic creation/refresh of child widgets from a data map.

AttrMapType

child attribute (value of the ‘kwargs’ and ‘attributes’ keys)

alias of Dict[str, Any]

DataItemValueType

item dict value (str for ‘cls’ key, dict for ‘kwargs’/’attributes’)

alias of Union[str, Dict[str, Any]]

DataItemType

DynamicChildrenBehavior.child_data_maps item type

alias of Dict[str, Union[str, Dict[str, Any]]]

ChildrenDataType

DynamicChildrenBehavior.child_data_maps type

alias of List[Dict[str, Union[str, Dict[str, Any]]]]

_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.

Return type:

Dict[str, Any]

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 a ListProperty 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 (via deep_replace()).

child_data_maps is a ListProperty and defaults to an empty list.

bind: Callable
container: Widget
_container: Widget
__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).