Skip to content

Commit

Permalink
Merge pull request #303 from maxfordham/301-indenting-not-consistent
Browse files Browse the repository at this point in the history
🐛 Fix indenting of widgets in AutoObject
  • Loading branch information
ollyhensby authored Mar 21, 2024
2 parents 2ee81a4 + fa15e67 commit 0065d9c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/ipyautoui/autobox.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
self.hbx_title_description,
]
),
self.widget,
w.HBox([SPACER, self.widget]),
]
f2 = lambda self: [
w.HBox(
Expand Down
9 changes: 7 additions & 2 deletions src/ipyautoui/autoobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,14 +378,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:
Expand Down
4 changes: 3 additions & 1 deletion src/ipyautoui/nullable.py
Original file line number Diff line number Diff line change
@@ -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"})


Expand Down

0 comments on commit 0065d9c

Please sign in to comment.