From 58ceded98cbf00e40af02994d736aa1a04ae222e Mon Sep 17 00:00:00 2001 From: JCzic Date: Tue, 4 Apr 2023 17:13:22 +0200 Subject: [PATCH] Remove splash screen on Linux --- src/app.py | 59 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 21 deletions(-) diff --git a/src/app.py b/src/app.py index e76534a..5223a0b 100755 --- a/src/app.py +++ b/src/app.py @@ -38,6 +38,7 @@ def __init__(self) : self._appRunning = False self._ws = None + self._splashScr = None self.esp32Ctrl = None self._deviceReadyToCmd = False self._wsMsgQueue = SimpleQueue() @@ -52,14 +53,15 @@ def __init__(self) : self._webSrv.WebSocketThreaded = True self._webSrv.AcceptWebSocketCallback = self._wsAcceptCallback - self._splashScr = webview.create_window( '', - url = self._localURL(conf.HTML_SPLASH_SCREEN_FILENAME), - width = 250, - height = 250, - resizable = False, - frameless = True, - on_top = True ) - self._splashScr.events.closed += self._onSplashScrClosed + if not conf.IS_LINUX : + self._splashScr = webview.create_window( '', + url = self._localURL(conf.HTML_SPLASH_SCREEN_FILENAME), + width = 250, + height = 250, + resizable = False, + frameless = True, + on_top = True ) + self._splashScr.events.closed += self._onSplashScrClosed self._mainWin = webview.create_window( '%s v%s' % (conf.APPLICATION_TITLE, conf.APPLICATION_STR_VERSION), url = self._localURL(conf.HTML_APP_MAIN_FILENAME), @@ -67,7 +69,7 @@ def __init__(self) : height = 710, resizable = True, min_size = (700, 550), - hidden = not conf.IS_LINUX ) + hidden = (self._splashScr is not None) ) self._mainWin.events.closing += self._onMainWinClosing self._mainWin.events.closed += self._onMainWinClosed @@ -289,12 +291,13 @@ def _wsProcessMessage(self, o) : # ------------------------------------------------------------------------ def _wsAcceptCallback(self, webSocket, httpClient) : - if not self._ws and self._splashScr : + if not self._ws : self._ws = webSocket webSocket.RecvTextCallback = self._wsRecvTextCallback webSocket.ClosedCallback = self._wsClosedCallback self._sendAppInfo() - self._splashScr.destroy() + if self._splashScr : + self._splashScr.destroy() else : webSocket.Close() @@ -1560,10 +1563,7 @@ async def _asyncAppRun(self) : if not conf.IS_WIN32 : print( '\n' + 'Application error :\n' + - 'Unable to initialize GUI...\n' + - 'You can try to force the web engine with following argument:\n' + - ' python app.py -g gtk (to use GTK on Linux)\n' + - ' python app.py -g qt (to use QT)\n' ) + 'Exceeded time limit during initialization...\n' ) os._exit(1) while True : for i in range(conf.RECURRENT_TIMER_APP_SEC * 10) : @@ -1604,12 +1604,29 @@ def Start(self) : forceGUI = arg if not conf.IS_WIN32 : print('Starts %s v%s on %s' % (conf.APPLICATION_TITLE, conf.APPLICATION_STR_VERSION, conf.OS_NAME)) - self._webSrv.Start(threaded=True) - webview.start( self._appRun, - localization = conf.PYWEBVIEW_LOCALIZATION, - user_agent = conf.APPLICATION_TITLE, - storage_path = (str(conf.DIRECTORY_FILES) if conf.IS_WIN32 else None), - gui = forceGUI ) + try : + self._webSrv.Start(threaded=True) + try : + webview.start( self._appRun, + localization = conf.PYWEBVIEW_LOCALIZATION, + user_agent = conf.APPLICATION_TITLE, + storage_path = (str(conf.DIRECTORY_FILES) if conf.IS_WIN32 else None), + gui = forceGUI ) + except Exception as ex : + if not conf.IS_WIN32 : + print( '\n' + + 'Application error:\n' + + 'Unable to initialize UI...\n' + + '%s\n\n' % ex + + 'You can try to force the web engine with following argument:\n' + + ' python app.py -g gtk (to use GTK on Linux first)\n' + + ' python app.py -g qt (to use QT first)\n' ) + except Exception as ex : + if not conf.IS_WIN32 : + print( '\n' + + 'Application error:\n' + + 'Unable to initialize internal Web server for UI...' + + '%s\n' % ex ) self._appRunning = False # ============================================================================