From 60c5addc3f040f52d05f4613270898d335bbad43 Mon Sep 17 00:00:00 2001 From: appel_c Date: Fri, 11 Apr 2025 18:02:00 +0200 Subject: [PATCH] fix(moduar-toolbar): fix cleanup of modular toolbar and dock_area --- bec_widgets/utils/side_panel.py | 4 ++-- bec_widgets/utils/toolbar.py | 2 +- bec_widgets/widgets/containers/dock/dock_area.py | 8 +------- bec_widgets/widgets/plots/plot_base.py | 2 +- .../plots/waveform/settings/curve_settings/curve_tree.py | 2 +- bec_widgets/widgets/services/bec_queue/bec_queue.py | 1 + 6 files changed, 7 insertions(+), 12 deletions(-) diff --git a/bec_widgets/utils/side_panel.py b/bec_widgets/utils/side_panel.py index 955231f1..e8249542 100644 --- a/bec_widgets/utils/side_panel.py +++ b/bec_widgets/utils/side_panel.py @@ -59,7 +59,7 @@ class SidePanel(QWidget): self.main_layout.setContentsMargins(0, 0, 0, 0) self.main_layout.setSpacing(0) - self.toolbar = ModularToolBar(target_widget=self, orientation="vertical") + self.toolbar = ModularToolBar(parent=self, target_widget=self, orientation="vertical") self.container = QWidget() self.container.layout = QVBoxLayout(self.container) @@ -89,7 +89,7 @@ class SidePanel(QWidget): self.main_layout.setContentsMargins(0, 0, 0, 0) self.main_layout.setSpacing(0) - self.toolbar = ModularToolBar(target_widget=self, orientation="horizontal") + self.toolbar = ModularToolBar(parent=self, target_widget=self, orientation="horizontal") self.container = QWidget() self.container.layout = QVBoxLayout(self.container) diff --git a/bec_widgets/utils/toolbar.py b/bec_widgets/utils/toolbar.py index ce042bfc..21a9ec1a 100644 --- a/bec_widgets/utils/toolbar.py +++ b/bec_widgets/utils/toolbar.py @@ -521,7 +521,7 @@ class ModularToolBar(QToolBar): orientation: Literal["horizontal", "vertical"] = "horizontal", background_color: str = "rgba(0, 0, 0, 0)", ): - super().__init__(parent) + super().__init__(parent=parent) self.widgets = defaultdict(dict) self.background_color = background_color diff --git a/bec_widgets/widgets/containers/dock/dock_area.py b/bec_widgets/widgets/containers/dock/dock_area.py index 01d6e69f..f39aa8b3 100644 --- a/bec_widgets/widgets/containers/dock/dock_area.py +++ b/bec_widgets/widgets/containers/dock/dock_area.py @@ -102,7 +102,7 @@ class BECDockArea(BECWidget, QWidget): self._instructions_visible = True self.dark_mode_button = DarkModeButton(parent=self, parent_id=self.gui_id, toolbar=True) - self.dock_area = DockArea() + self.dock_area = DockArea(parent=self) self.toolbar = ModularToolBar( parent=self, actions={ @@ -440,12 +440,6 @@ class BECDockArea(BECWidget, QWidget): Cleanup the dock area. """ self.delete_all() - self.toolbar.close() - self.toolbar.deleteLater() - self.dark_mode_button.close() - self.dark_mode_button.deleteLater() - self.dock_area.close() - self.dock_area.deleteLater() super().cleanup() def show(self): diff --git a/bec_widgets/widgets/plots/plot_base.py b/bec_widgets/widgets/plots/plot_base.py index 2cddb08d..711bbe2c 100644 --- a/bec_widgets/widgets/plots/plot_base.py +++ b/bec_widgets/widgets/plots/plot_base.py @@ -101,7 +101,7 @@ class PlotBase(BECWidget, QWidget): self.plot_item = pg.PlotItem(viewBox=BECViewBox(enableMenu=True)) self.plot_widget.addItem(self.plot_item) self.side_panel = SidePanel(self, orientation="left", panel_max_width=280) - self.toolbar = ModularToolBar(target_widget=self, orientation="horizontal") + self.toolbar = ModularToolBar(parent=self, target_widget=self, orientation="horizontal") self._init_toolbar() # PlotItem Addons diff --git a/bec_widgets/widgets/plots/waveform/settings/curve_settings/curve_tree.py b/bec_widgets/widgets/plots/waveform/settings/curve_settings/curve_tree.py index 9805c3eb..a2f96776 100644 --- a/bec_widgets/widgets/plots/waveform/settings/curve_settings/curve_tree.py +++ b/bec_widgets/widgets/plots/waveform/settings/curve_settings/curve_tree.py @@ -386,7 +386,7 @@ class CurveTree(BECWidget, QWidget): def _init_toolbar(self): """Initialize the toolbar with actions: add, send, refresh, expand, collapse, renormalize.""" - self.toolbar = ModularToolBar(target_widget=self, orientation="horizontal") + self.toolbar = ModularToolBar(parent=self, target_widget=self, orientation="horizontal") add = MaterialIconAction( icon_name="add", tooltip="Add new curve", checkable=False, parent=self ) diff --git a/bec_widgets/widgets/services/bec_queue/bec_queue.py b/bec_widgets/widgets/services/bec_queue/bec_queue.py index 3f9ba3f7..6dbc5158 100644 --- a/bec_widgets/widgets/services/bec_queue/bec_queue.py +++ b/bec_widgets/widgets/services/bec_queue/bec_queue.py @@ -76,6 +76,7 @@ class BECQueue(BECWidget, CompactPopupWidget): widget_label = QLabel("Live Queue") widget_label.setStyleSheet("font-weight: bold;") self.toolbar = ModularToolBar( + parent=self, actions={ "widget_label": WidgetAction(widget=widget_label), "separator_1": SeparatorAction(),