fix splash loading with wx3.0
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Wed, 20 Apr 2016 17:15:35 +0300
changeset 1489 9c22ff9c8c06
parent 1488 00fb79aba7ac
child 1490 f03bc6c9c146
fix splash loading with wx3.0

Previously only gray square was shown. Apparently to show splash screen several calls of wx.Yield() are necessary.
Unfortunately splash.IsShowOnScreen() returns always 1 regardless of whether splash is on the screen or not.
this fix is a dirty hack. It just process all events after splash is created during 0.3 seconds.
Beremiz.py
--- a/Beremiz.py	Wed Apr 20 16:20:53 2016 +0300
+++ b/Beremiz.py	Wed Apr 20 17:15:35 2016 +0300
@@ -43,6 +43,18 @@
 def Bpath(*args):
     return os.path.join(beremiz_dir,*args)
 
+def ShowSplashScreen():
+    bmp = wx.Image(Bpath("images", "splash.png")).ConvertToBitmap()
+    #splash=AdvancedSplash(None, bitmap=bmp, style=wx.SPLASH_CENTRE_ON_SCREEN, timeout=4000)
+    splash = AdvancedSplash(None, bitmap=bmp)
+
+    # process all events
+    # even the events generated by splash themself during showing
+    for i in range(0,30):
+        wx.Yield()
+        time.sleep(0.01);
+    return splash
+
 if __name__ == '__main__':
     def usage():
         print "\nUsage of Beremiz.py :"
@@ -94,11 +106,8 @@
 	wx.InitAllImageHandlers()
 
     # popup splash
-    bmp = wx.Image(Bpath("images", "splash.png")).ConvertToBitmap()
-    #splash=AdvancedSplash(None, bitmap=bmp, style=wx.SPLASH_CENTRE_ON_SCREEN, timeout=4000)
-    splash=AdvancedSplash(None, bitmap=bmp)
-    wx.Yield()
-
+    splash = ShowSplashScreen()
+    
     if updateinfo_url is not None:
         updateinfo = "Fetching %s" % updateinfo_url
         # warn for possible updates