Skip to content

Commit

Permalink
NewInstanceWidget: Keep previous trait values
Browse files Browse the repository at this point in the history
when switching type
  • Loading branch information
rhaschke committed Nov 30, 2023
1 parent adf26bb commit fad7406
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions python/stack_of_tasks/ui/widgets/has_trait_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(self, parent=None, cls=None) -> None:
self.setLayout(self.fl)

def _setup_widgets(self):
old_args = {k: get_user_property(v) for k, v in self.args.items()}
self.args.clear()

while self.fl.rowCount() > 0:
Expand All @@ -54,13 +55,10 @@ def _setup_widgets(self):
if me is not None:
widget = me.widget()
me.setup_function(trait, widget)
set_user_property(widget, trait.trait_type.default_value)

else:
continue

self.fl.addRow(name, widget)
self.args[name] = widget
value = old_args.get(name, trait.trait_type.default_value)
set_user_property(widget, value)
self.fl.addRow(name, widget)
self.args[name] = widget

def get_arguments(self) -> dict["str", Any]:
r = {}
Expand Down

0 comments on commit fad7406

Please sign in to comment.