From 4b32281fe7ae8e2c1c52ec70b3667602079813a8 Mon Sep 17 00:00:00 2001 From: Edan Bainglass Date: Fri, 1 Nov 2024 06:39:36 +0000 Subject: [PATCH] Handle process-loaded structure assignment more cleanly --- src/aiidalab_qe/app/structure/__init__.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/aiidalab_qe/app/structure/__init__.py b/src/aiidalab_qe/app/structure/__init__.py index 95fd2908e..a22487302 100644 --- a/src/aiidalab_qe/app/structure/__init__.py +++ b/src/aiidalab_qe/app/structure/__init__.py @@ -91,14 +91,6 @@ def render(self): plugin_editors = get_entry_items("aiidalab_qe.properties", "editor") editors.extend([editor() for editor in plugin_editors.values()]) - # HACK structure manager resets the structure node on initialization, - # causing the structure in the model (if exists) to reset. To avoid - # this issue, we store the structure in a variable and assign it to - # the manager's viewer after the initialization of the structure manager. - # TODO fix this issue in the structure manager and remove this hack! - - structure = self._model.structure - self.manager = StructureManagerWidget( importers=importers, editors=editors, @@ -111,6 +103,9 @@ def render(self): "Download", ], ) + # A structure may have been loaded from a structure, + # so we assign it here as the manager's input structure. + self.manager.input_structure = self._model.structure ipw.dlink( (self.manager, "structure_node"), (self._model, "structure"), @@ -120,9 +115,6 @@ def render(self): (self.manager.output, "value"), ) - if structure: # loaded from process - self.manager.viewer.structure = structure - self.structure_name_text = ipw.Text( placeholder="[No structure selected]", description="Selected:",