Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/techui_builder/autofill.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def replace_content(

assert current_widget is not None
# Remove all existing macros if they exist
if current_widget.macros is not None:
if hasattr(current_widget, "macros"):
current_widget.remove(current_widget.macros)
# Create new macros element
current_widget.append(
Expand Down Expand Up @@ -137,7 +137,7 @@ def _create_macro_element(self, macros: dict):
macros_element = Element("macros")
for macro, val in macros.items():
macro_element = SubElement(macros_element, macro)
macro_element.text = val
macro_element.text = str(val)

# ... which requires this horror
obj_macros_element = fromstring(tostring(macros_element))
Expand Down
18 changes: 10 additions & 8 deletions src/techui_builder/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ def get_widgets(root: ObjectifiedElement):
# but not any nested tags below them
for child in root.iterchildren():
# If widget is a symbol (i.e. a component)
if child.tag == "widget" and child.get("type", default=None) in [
"symbol",
"group",
]:
name = child.name.text
assert name is not None
widgets[name] = child

if child.tag == "widget":
match child.get("type", default=None):
case "action_button" | "symbol":
name = child.name.text
assert name is not None
widgets[name] = child
case "group":
# Get all the widgets inside of the group objects
groups_widgets = get_widgets(child)
widgets.update(groups_widgets)
return widgets