--- a/Beremiz.py Fri Feb 16 18:24:55 2018 +0100
+++ b/Beremiz.py Fri Feb 16 18:38:30 2018 +0100
@@ -31,11 +31,10 @@
import time
import wx
-from wx.lib.agw.advancedsplash import AdvancedSplash
+from wx.lib.agw.advancedsplash import AdvancedSplash, AS_NOTIMEOUT, AS_CENTER_ON_SCREEN
import util.paths as paths
-
class BeremizIDELauncher(object):
def __init__(self):
self.app = None
@@ -55,17 +54,8 @@
def ShowSplashScreen(self):
bmp = wx.Image(self.splashPath).ConvertToBitmap()
- self.splash = AdvancedSplash(None, bitmap=bmp)
-
- # process all events
- # even the events generated by splash themself during showing
- if wx.Platform == '__WXMSW__':
- self.splash.Show()
- self.splash.ProcessEvent(wx.PaintEvent())
- else:
- for dummy in range(0, 30):
- wx.Yield()
- time.sleep(0.01)
+ self.splash = AdvancedSplash(None, bitmap=bmp, agwStyle=AS_NOTIMEOUT | AS_CENTER_ON_SCREEN)
+
def Usage(self):
print("Usage:")
@@ -115,11 +105,15 @@
self.buildpath = args[1]
def CreateApplication(self):
- if wx.VERSION >= (3, 0, 0):
- self.app = wx.App(redirect=self.debug)
- else:
- self.app = wx.PySimpleApp(redirect=self.debug)
-
+
+ BeremizAppType = wx.App if wx.VERSION >= (3, 0, 0) else wx.PySimpleApp
+ class BeremizApp(BeremizAppType):
+ def OnInit(_self):
+ self.ShowSplashScreen()
+ wx.CallAfter(self.AppStart)
+ return True
+
+ self.app = BeremizApp(redirect=self.debug)
self.app.SetAppName('beremiz')
if wx.VERSION < (3, 0, 0):
wx.InitAllImageHandlers()
@@ -129,7 +123,6 @@
self.CheckUpdates()
self.LoadExtensions()
self.ImportModules()
- self.InstallExceptionHandler()
def InitI18n(self):
from util.misc import InstallLocalRessources
@@ -178,7 +171,7 @@
def InstallExceptionHandler(self):
import version
import util.ExceptionHandler
- util.ExceptionHandler.AddExceptHook(version.app_version)
+ self.handle_exception = util.ExceptionHandler.AddExceptHook(version.app_version)
def CreateUI(self):
self.frame = self.BeremizIDE.Beremiz(None, self.projectOpen, self.buildpath)
@@ -193,17 +186,24 @@
def PreStart(self):
self.ProcessCommandLineArgs()
self.CreateApplication()
- self.ShowSplashScreen()
- self.BackgroundInitialization()
- self.CreateUI()
- self.CloseSplash()
+
+ def AppStart(self):
+ try:
+ self.BackgroundInitialization()
+ self.CreateUI()
+ self.CloseSplash()
+ self.ShowUI()
+ # except (KeyboardInterrupt, SystemExit):
+ # raise
+ except Exception:
+ self.handle_exception(*sys.exc_info(), exit = True)
def MainLoop(self):
self.app.MainLoop()
def Start(self):
self.PreStart()
- self.ShowUI()
+ self.InstallExceptionHandler()
self.MainLoop()