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 container widgets (like DropDowns, Popups or any layout widgets).

Classes

DynamicChildrenBehavior(**kwargs)

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

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_maps: List[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_container’ 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 deep_object()). all values in this dict with the magic string ‘replace_with_data_map_container’ 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: kivy.uix.widget.Widget
_container: kivy.uix.widget.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).