diff --git a/src/aiidalab_qe/common/bands_pdos/bandpdoswidget.py b/src/aiidalab_qe/common/bands_pdos/bandpdoswidget.py index 527300bd..540e231e 100644 --- a/src/aiidalab_qe/common/bands_pdos/bandpdoswidget.py +++ b/src/aiidalab_qe/common/bands_pdos/bandpdoswidget.py @@ -160,18 +160,6 @@ def render(self): layout=ipw.Layout(display="none"), ) - # self.plot_button = ipw.Button( - # description="Plot", - # icon="line-chart", - # button_style="success", - # ) - # ipw.dlink( - # (self._model, "ready"), - # (self.plot_button, "disabled"), - # lambda ready: not ready, - # ) - # self.plot_button.on_click(self._update_plot) - self.pdos_options = ipw.VBox( children=[ ipw.HTML(""" @@ -218,11 +206,6 @@ def render(self): """), self.pdos_options, self.download_button, - # ipw.HBox( - # children=[ - # self.plot_button, - # ], - # ), self.legend_interaction_description, self.bands_widget, ] diff --git a/src/aiidalab_qe/common/bands_pdos/model.py b/src/aiidalab_qe/common/bands_pdos/model.py index ec41b55a..bf1eb844 100644 --- a/src/aiidalab_qe/common/bands_pdos/model.py +++ b/src/aiidalab_qe/common/bands_pdos/model.py @@ -45,35 +45,23 @@ class BandsPdosModel(Model): needs_pdos_options = tl.Bool(False) needs_projections_controls = tl.Bool(False) - ready = tl.Bool(False) - def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) ipw.dlink( (self, "bands"), (self, "needs_projections_controls"), - lambda node: node is not None and "projwfc" in node, + lambda _: self._has_bands_projections, ) ipw.dlink( (self, "pdos"), (self, "needs_pdos_options"), - lambda _: self.pdos is not None or self.needs_projections_controls, + lambda _: self._has_pdos or self.needs_projections_controls, ) ipw.dlink( (self, "needs_projections_controls"), (self, "needs_pdos_options"), - lambda _: self.pdos is not None or self.needs_projections_controls, - ) - ipw.dlink( - (self, "bands"), - (self, "ready"), - lambda node: bool(node), - ) - ipw.dlink( - (self, "pdos"), - (self, "ready"), - lambda node: bool(node), + lambda _: self._has_pdos or self.needs_projections_controls, ) def fetch_data(self): @@ -83,6 +71,18 @@ def fetch_data(self): if self.pdos: self.pdos_data = self._get_pdos_data() + @property + def _has_bands(self): + return bool(self.bands) + + @property + def _has_pdos(self): + return bool(self.pdos) + + @property + def _has_bands_projections(self): + return self._has_bands and "projwfc" in self.bands + def _get_pdos_data(self): if not self.pdos: return None