From fa15e673007da4eb79c856623dee176974fc5f1f Mon Sep 17 00:00:00 2001 From: Oliver Hensby Date: Thu, 21 Mar 2024 14:30:49 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20indenting=20of=20widgets?= =?UTF-8?q?=20in=20AutoObject?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ipyautoui/autobox.py | 2 +- src/ipyautoui/autoobject.py | 9 +++++++-- src/ipyautoui/nullable.py | 4 +++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/ipyautoui/autobox.py b/src/ipyautoui/autobox.py index b5fa244e..c930ab4c 100644 --- a/src/ipyautoui/autobox.py +++ b/src/ipyautoui/autobox.py @@ -40,7 +40,7 @@ self.hbx_title_description, ] ), - self.widget, + w.HBox([SPACER, self.widget]), ] f2 = lambda self: [ w.HBox( diff --git a/src/ipyautoui/autoobject.py b/src/ipyautoui/autoobject.py index bdda2a73..b2e49fa5 100644 --- a/src/ipyautoui/autoobject.py +++ b/src/ipyautoui/autoobject.py @@ -379,14 +379,19 @@ def _init_widgets(self): for k in self.di_callers.keys() } self.vbx_widget.children = list(self.di_boxes.values()) - self.indent_non_nullable() + self.indent_widgets() - def indent_non_nullable(self): + def indent_widgets(self): + """Indent the widgets appropriately based on the schema. + Any widget that is not nullable and has a type of "array" will be indented.""" li = [v.allow_none for v in self.di_callers.values()] if True in li: for k, v in self.di_callers.items(): if not v.allow_none: self.di_boxes[k].indent = True + if "type" in v.kwargs and v.kwargs["type"] == "array": + self.di_boxes[k].indent = True + def _insert_rows(self): if self.insert_rows is not None: diff --git a/src/ipyautoui/nullable.py b/src/ipyautoui/nullable.py index 19603d4e..ae0598e2 100644 --- a/src/ipyautoui/nullable.py +++ b/src/ipyautoui/nullable.py @@ -1,8 +1,10 @@ import functools +import pandas as pd import ipywidgets as w import traitlets as tr + from ipyautoui.constants import BUTTON_WIDTH_MIN -import pandas as pd + SHOW_NONE_KWARGS = dict(value="None", disabled=True, layout={"display": "None"})