diff --git a/b_asic/GUI/main_window.py b/b_asic/GUI/main_window.py index a9aac1007ef28a52380f9bb8d1c68431533409a9..86024d645ba58f5b28440e155dd0ffb63e31112b 100644 --- a/b_asic/GUI/main_window.py +++ b/b_asic/GUI/main_window.py @@ -804,7 +804,23 @@ class SFGMainWindow(QMainWindow): def start_editor(sfg: Optional[SFG] = None) -> Dict[str, SFG]: - app = QApplication(sys.argv) + """ + Start the SFG editor. + + Parameters + ---------- + sfg : SFG, optional + The SFG to start the editor with. + + Returns + ------- + dict + All SFGs currently in the editor. + """ + if not QApplication.instance(): + app = QApplication(sys.argv) + else: + app = QApplication.instance() window = SFGMainWindow() if sfg: window._load_sfg(sfg) diff --git a/b_asic/gui_utils/plot_window.py b/b_asic/gui_utils/plot_window.py index 2c6af52a2f80222c334d31e6d6da646f3f428730..991baaea088fff07e1dd88c71e06c46d036f6f33 100644 --- a/b_asic/gui_utils/plot_window.py +++ b/b_asic/gui_utils/plot_window.py @@ -256,10 +256,13 @@ def start_simulation_dialog( sfg_name : str, optional The name of the SFG. """ - app = QApplication(sys.argv) + if not QApplication.instance(): + app = QApplication(sys.argv) + else: + app = QApplication.instance() win = PlotWindow(sim_result=sim_results, sfg_name=sfg_name) win.show() - sys.exit(app.exec_()) + app.exec_() # Simple test of the dialog diff --git a/b_asic/scheduler_gui/main_window.py b/b_asic/scheduler_gui/main_window.py index 4b379c7549e6406c9ed7417159a3438c3f559ab6..e561725c210d3324d37bd04e237b66c1d75b057f 100644 --- a/b_asic/scheduler_gui/main_window.py +++ b/b_asic/scheduler_gui/main_window.py @@ -706,7 +706,23 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): def start_scheduler(schedule: Optional[Schedule] = None) -> Schedule: - app = QApplication(sys.argv) + """ + Start scheduler GUI. + + Parameters + ---------- + schedule : Schedule, optional + The schedule to start the editor with. + + Returns + ------- + Schedule + The edited schedule. + """ + if not QApplication.instance(): + app = QApplication(sys.argv) + else: + app = QApplication.instance() window = ScheduleMainWindow() if schedule: window.open(schedule)