From 12469c8c1e45f83cc0c65708bd412103a8ec1838 Mon Sep 17 00:00:00 2001 From: wyzula-jan <133381102+wyzula-jan@users.noreply.github.com> Date: Thu, 26 Oct 2023 15:44:02 +0200 Subject: [PATCH] fix: config_dialog.py prevents to add one scan twice --- bec_widgets/widgets/monitor/config_dialog.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bec_widgets/widgets/monitor/config_dialog.py b/bec_widgets/widgets/monitor/config_dialog.py index f053db1e..8f87919a 100644 --- a/bec_widgets/widgets/monitor/config_dialog.py +++ b/bec_widgets/widgets/monitor/config_dialog.py @@ -206,6 +206,11 @@ class ConfigDialog(QWidget, Ui_Form): Returns: scan_tab(QWidget): Scan tab widget """ + # Check for an existing tab with the same name + for index in range(parent_tab.count()): + if parent_tab.tabText(index) == scan_name: + print(f'Scan name "{scan_name}" already exists.') + return None # or return the existing tab: return parent_tab.widget(index) # Create a new scan tab scan_tab = QWidget() @@ -305,7 +310,8 @@ class ConfigDialog(QWidget, Ui_Form): """ scan_tab = self.add_new_scan(parent_tab, scan_name, closable=True) - self.add_new_plot(scan_tab) + if scan_tab is not None: + self.add_new_plot(scan_tab) def get_plot_config(self, plot_tab: QWidget) -> dict: """