0
0
mirror of https://github.com/bec-project/bec_widgets.git synced 2025-07-14 03:31:50 +02:00

WIP BECDispatcher starts with passed gui id CLI Server

This commit is contained in:
2025-04-06 16:41:46 +02:00
parent 70469c83cc
commit 3a3a143cf8
2 changed files with 13 additions and 5 deletions

View File

@ -105,14 +105,14 @@ class GUIServer:
"""
Run the GUI server.
"""
# TODO decide if attach to app or not
self.app = QApplication(sys.argv)
self.app.setApplicationName("BEC")
self.app.gui_id = self.gui_id # type: ignore
self.setup_bec_icon()
service_config = self._get_service_config()
self.dispatcher = BECDispatcher(config=service_config)
self.dispatcher.start_cli_server(gui_id=self.gui_id)
self.dispatcher = BECDispatcher(config=service_config, gui_id=self.gui_id)
self.launcher_window = LaunchWindow(gui_id=f"{self.gui_id}:launcher")
self.launcher_window.setAttribute(Qt.WA_ShowWithoutActivating) # type: ignore

View File

@ -80,13 +80,21 @@ class BECDispatcher:
client: BECClient
cli_server: CLIServer | None = None
def __new__(cls, client=None, config: str | ServiceConfig | None = None, *args, **kwargs):
# TODO add custom gui id for server
def __new__(
cls,
client=None,
config: str | ServiceConfig | None = None,
gui_id: str = None,
*args,
**kwargs,
):
if cls._instance is None:
cls._instance = super(BECDispatcher, cls).__new__(cls)
cls._initialized = False
return cls._instance
def __init__(self, client=None, config: str | ServiceConfig | None = None):
def __init__(self, client=None, config: str | ServiceConfig | None = None, gui_id: str = None):
if self._initialized:
return
@ -115,7 +123,7 @@ class BECDispatcher:
logger.success("Initialized BECDispatcher")
self.start_cli_server()
self.start_cli_server(gui_id=gui_id)
self._initialized = True
@classmethod