diff --git a/src/aiidalab_qe/common/panel.py b/src/aiidalab_qe/common/panel.py index 5224efc27..0620c382d 100644 --- a/src/aiidalab_qe/common/panel.py +++ b/src/aiidalab_qe/common/panel.py @@ -287,6 +287,10 @@ def _toggle_code(self, code_model: CodeModel): code_widget = self.code_widgets[code_model.name] if not code_model.is_rendered: self._render_code_widget(code_model, code_widget) + code_widget.observe( + code_widget.update_resources, + "value", + ) def _render_code_widget( self, @@ -299,7 +303,7 @@ def _render_code_widget( ) ipw.link( (code_model, "selected"), - (code_widget.code_selection.code_select_dropdown, "value"), + (code_widget, "value"), ) ipw.link( (code_model, "num_cpus"), diff --git a/src/aiidalab_qe/common/widgets.py b/src/aiidalab_qe/common/widgets.py index b42301083..b36f4c6f6 100644 --- a/src/aiidalab_qe/common/widgets.py +++ b/src/aiidalab_qe/common/widgets.py @@ -674,8 +674,7 @@ def __init__(self, **kwargs): ) traitlets.link((self.code_selection, "value"), (self, "value")) - @traitlets.observe("value") - def _update_resources(self, change): + def update_resources(self, change): if change["new"]: self.set_resource_defaults(load_code(change["new"]).computer)