From 80fa9fde6ab0ca6ea2e3806be69a350c0e0e0450 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Mon, 8 Aug 2022 23:49:26 +0300 Subject: [PATCH] Quit GUI via SysTray instead of sys.exit to cleanly terminate server --- src/main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.py b/src/main.py index dc223f48..cf5842f6 100644 --- a/src/main.py +++ b/src/main.py @@ -28,7 +28,7 @@ def run(): # Setup GUI gui = QtWidgets.QApplication([]) gui.setQuitOnLastWindowClosed(False) - tray = create_system_tray() + tray = create_system_tray(gui) window = ConfigureWindow() # Start Application Server @@ -102,7 +102,7 @@ class ConfigureWindow(QtWidgets.QMainWindow): self.config_window.layout().removeWidget(self.config_window.layout().itemAt(2).widget()) -def create_system_tray(): +def create_system_tray(gui: QtWidgets.QApplication): """Create System Tray with Menu Menu Actions should contain 1. option to open search page at localhost:8000/ @@ -121,7 +121,7 @@ def create_system_tray(): menu_actions = [ ('Search', lambda: webbrowser.open('http://localhost:8000/')), ('Configure', lambda: webbrowser.open('http://localhost:8000/config')), - ('Quit', sys.exit), + ('Quit', gui.quit), ] # Add the menu actions to the menu