Skip to content

Commit 58ceded

Browse files
committed
Remove splash screen on Linux
1 parent d5a07ed commit 58ceded

1 file changed

Lines changed: 38 additions & 21 deletions

File tree

src/app.py

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def __init__(self) :
3838

3939
self._appRunning = False
4040
self._ws = None
41+
self._splashScr = None
4142
self.esp32Ctrl = None
4243
self._deviceReadyToCmd = False
4344
self._wsMsgQueue = SimpleQueue()
@@ -52,22 +53,23 @@ def __init__(self) :
5253
self._webSrv.WebSocketThreaded = True
5354
self._webSrv.AcceptWebSocketCallback = self._wsAcceptCallback
5455

55-
self._splashScr = webview.create_window( '',
56-
url = self._localURL(conf.HTML_SPLASH_SCREEN_FILENAME),
57-
width = 250,
58-
height = 250,
59-
resizable = False,
60-
frameless = True,
61-
on_top = True )
62-
self._splashScr.events.closed += self._onSplashScrClosed
56+
if not conf.IS_LINUX :
57+
self._splashScr = webview.create_window( '',
58+
url = self._localURL(conf.HTML_SPLASH_SCREEN_FILENAME),
59+
width = 250,
60+
height = 250,
61+
resizable = False,
62+
frameless = True,
63+
on_top = True )
64+
self._splashScr.events.closed += self._onSplashScrClosed
6365

6466
self._mainWin = webview.create_window( '%s v%s' % (conf.APPLICATION_TITLE, conf.APPLICATION_STR_VERSION),
6567
url = self._localURL(conf.HTML_APP_MAIN_FILENAME),
6668
width = 1030,
6769
height = 710,
6870
resizable = True,
6971
min_size = (700, 550),
70-
hidden = not conf.IS_LINUX )
72+
hidden = (self._splashScr is not None) )
7173
self._mainWin.events.closing += self._onMainWinClosing
7274
self._mainWin.events.closed += self._onMainWinClosed
7375

@@ -289,12 +291,13 @@ def _wsProcessMessage(self, o) :
289291
# ------------------------------------------------------------------------
290292

291293
def _wsAcceptCallback(self, webSocket, httpClient) :
292-
if not self._ws and self._splashScr :
294+
if not self._ws :
293295
self._ws = webSocket
294296
webSocket.RecvTextCallback = self._wsRecvTextCallback
295297
webSocket.ClosedCallback = self._wsClosedCallback
296298
self._sendAppInfo()
297-
self._splashScr.destroy()
299+
if self._splashScr :
300+
self._splashScr.destroy()
298301
else :
299302
webSocket.Close()
300303

@@ -1560,10 +1563,7 @@ async def _asyncAppRun(self) :
15601563
if not conf.IS_WIN32 :
15611564
print( '\n' +
15621565
'Application error :\n' +
1563-
'Unable to initialize GUI...\n' +
1564-
'You can try to force the web engine with following argument:\n' +
1565-
' python app.py -g gtk (to use GTK on Linux)\n' +
1566-
' python app.py -g qt (to use QT)\n' )
1566+
'Exceeded time limit during initialization...\n' )
15671567
os._exit(1)
15681568
while True :
15691569
for i in range(conf.RECURRENT_TIMER_APP_SEC * 10) :
@@ -1604,12 +1604,29 @@ def Start(self) :
16041604
forceGUI = arg
16051605
if not conf.IS_WIN32 :
16061606
print('Starts %s v%s on %s' % (conf.APPLICATION_TITLE, conf.APPLICATION_STR_VERSION, conf.OS_NAME))
1607-
self._webSrv.Start(threaded=True)
1608-
webview.start( self._appRun,
1609-
localization = conf.PYWEBVIEW_LOCALIZATION,
1610-
user_agent = conf.APPLICATION_TITLE,
1611-
storage_path = (str(conf.DIRECTORY_FILES) if conf.IS_WIN32 else None),
1612-
gui = forceGUI )
1607+
try :
1608+
self._webSrv.Start(threaded=True)
1609+
try :
1610+
webview.start( self._appRun,
1611+
localization = conf.PYWEBVIEW_LOCALIZATION,
1612+
user_agent = conf.APPLICATION_TITLE,
1613+
storage_path = (str(conf.DIRECTORY_FILES) if conf.IS_WIN32 else None),
1614+
gui = forceGUI )
1615+
except Exception as ex :
1616+
if not conf.IS_WIN32 :
1617+
print( '\n' +
1618+
'Application error:\n' +
1619+
'Unable to initialize UI...\n' +
1620+
'%s\n\n' % ex +
1621+
'You can try to force the web engine with following argument:\n' +
1622+
' python app.py -g gtk (to use GTK on Linux first)\n' +
1623+
' python app.py -g qt (to use QT first)\n' )
1624+
except Exception as ex :
1625+
if not conf.IS_WIN32 :
1626+
print( '\n' +
1627+
'Application error:\n' +
1628+
'Unable to initialize internal Web server for UI...' +
1629+
'%s\n' % ex )
16131630
self._appRunning = False
16141631

16151632
# ============================================================================

0 commit comments

Comments
 (0)