diff --git a/src/ipyautoui/custom/iterable.py b/src/ipyautoui/custom/iterable.py index 54e25477..6d046e95 100644 --- a/src/ipyautoui/custom/iterable.py +++ b/src/ipyautoui/custom/iterable.py @@ -188,7 +188,10 @@ def _type(self, proposal): @tr.observe("length") def _length(self, on_change): if self.length == 0: - if self.add_remove_controls == ItemControl.append_only or self.add_remove_controls == ItemControl.append_only: + if ( + self.add_remove_controls == ItemControl.append_only + or self.add_remove_controls == ItemControl.append_only + ): self.display_bn_add_from_zero(True) else: pass @@ -223,9 +226,16 @@ def _add_remove_controls(self, on_change): def _align_horizontal(self, on_change): flip(self.bx_boxes, self.align_horizontal) - @property + @property def map_key_value(self): - return {b.key: (lambda w: w.value if hasattr(w, "value") or hasattr(w, "_value") else None)(b.widget.value) for b in self.boxes} + return { + b.key: ( + lambda w: w.value + if hasattr(w, "value") or hasattr(w, "_value") + else None + )(b.widget.value) + for b in self.boxes + } def display_bn_add_from_zero(self, display: bool): if display: @@ -254,7 +264,7 @@ def __init__(self, **kwargs): self._post_init(**kwargs) def _post_init(self, **kwargs): - pass # NOTE: this can be overwritten to provide customisation + pass # NOTE: this can be overwritten to provide customisation def _init_controls(self): [self._init_row_controls(key=i.key) for i in self.boxes] @@ -369,7 +379,7 @@ def remove_row(self, key=None, fn_onremove=None): ) return None if len(self.boxes) <= 1: - pass + self.display_bn_add_from_zero(display=True) if key is None: print("key is None") key = self.iterable[-1].key @@ -383,7 +393,6 @@ def remove_row(self, key=None, fn_onremove=None): self._watch_validate_change("") - class AutoArray(Array): allOf = tr.List(allow_none=True, default_value=None) items = tr.Dict(allow_none=True, default_value=None)