Skip to content

Commit 7d6ee91

Browse files
committed
Fix autofilling for widgets inside of groups in index.bob
1 parent e9c209d commit 7d6ee91

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/techui_builder/autofill.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def replace_content(
108108

109109
assert current_widget is not None
110110
# Remove all existing macros if they exist
111-
if current_widget.macros is not None:
111+
if getattr(current_widget, "macros", None) is not None:
112112
current_widget.remove(current_widget.macros)
113113
# Create new macros element
114114
current_widget.append(
@@ -137,7 +137,7 @@ def _create_macro_element(self, macros: dict):
137137
macros_element = Element("macros")
138138
for macro, val in macros.items():
139139
macro_element = SubElement(macros_element, macro)
140-
macro_element.text = val
140+
macro_element.text = str(val)
141141

142142
# ... which requires this horror
143143
obj_macros_element = fromstring(tostring(macros_element))

src/techui_builder/utils.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ def get_widgets(root: ObjectifiedElement):
2121
# but not any nested tags below them
2222
for child in root.iterchildren():
2323
# If widget is a symbol (i.e. a component)
24-
if child.tag == "widget" and child.get("type", default=None) in [
25-
"symbol",
26-
"group",
27-
]:
28-
name = child.name.text
29-
assert name is not None
30-
widgets[name] = child
31-
24+
if child.tag == "widget":
25+
match child.get("type", default=None):
26+
case "action_button" | "symbol":
27+
name = child.name.text
28+
assert name is not None
29+
widgets[name] = child
30+
case "group":
31+
# Get all the widgets inside of the group objects
32+
groups_widgets = get_widgets(child)
33+
widgets.update(groups_widgets)
3234
return widgets

0 commit comments

Comments
 (0)