26 from __future__ import absolute_import |
26 from __future__ import absolute_import |
27 from __future__ import print_function |
27 from __future__ import print_function |
28 import os |
28 import os |
29 import sys |
29 import sys |
30 import getopt |
30 import getopt |
31 import time |
|
32 |
31 |
33 import wx |
32 import wx |
34 from wx.lib.agw.advancedsplash import AdvancedSplash, AS_NOTIMEOUT, AS_CENTER_ON_SCREEN |
33 from wx.lib.agw.advancedsplash import AdvancedSplash, AS_NOTIMEOUT, AS_CENTER_ON_SCREEN |
35 |
34 |
36 import util.paths as paths |
35 import util.paths as paths |
|
36 |
37 |
37 |
38 class BeremizIDELauncher(object): |
38 class BeremizIDELauncher(object): |
39 def __init__(self): |
39 def __init__(self): |
40 self.app = None |
40 self.app = None |
41 self.frame = None |
41 self.frame = None |
100 self.buildpath = args[1] |
100 self.buildpath = args[1] |
101 |
101 |
102 def CreateApplication(self): |
102 def CreateApplication(self): |
103 |
103 |
104 BeremizAppType = wx.App if wx.VERSION >= (3, 0, 0) else wx.PySimpleApp |
104 BeremizAppType = wx.App if wx.VERSION >= (3, 0, 0) else wx.PySimpleApp |
|
105 |
105 class BeremizApp(BeremizAppType): |
106 class BeremizApp(BeremizAppType): |
106 def OnInit(_self): |
107 def OnInit(_self): # pylint: disable=no-self-argument |
107 self.ShowSplashScreen() |
108 self.ShowSplashScreen() |
108 return True |
109 return True |
109 |
110 |
110 self.app = BeremizApp(redirect=self.debug) |
111 self.app = BeremizApp(redirect=self.debug) |
111 self.app.SetAppName('beremiz') |
112 self.app.SetAppName('beremiz') |
112 if wx.VERSION < (3, 0, 0): |
113 if wx.VERSION < (3, 0, 0): |
113 wx.InitAllImageHandlers() |
114 wx.InitAllImageHandlers() |
114 |
115 |
115 def ShowSplashScreen(self): |
116 def ShowSplashScreen(self): |
116 class Splash(AdvancedSplash): |
117 class Splash(AdvancedSplash): |
117 def OnPaint(_self, event): |
118 def OnPaint(_self, event): # pylint: disable=no-self-argument |
118 AdvancedSplash.OnPaint(_self, event) |
119 AdvancedSplash.OnPaint(_self, event) |
119 wx.CallAfter(self.AppStart) |
120 wx.CallAfter(self.AppStart) |
120 bmp = wx.Image(self.splashPath).ConvertToBitmap() |
121 bmp = wx.Image(self.splashPath).ConvertToBitmap() |
121 self.splash = Splash(None, |
122 self.splash = Splash(None, |
122 bitmap=bmp, |
123 bitmap=bmp, |
123 agwStyle=AS_NOTIMEOUT | AS_CENTER_ON_SCREEN) |
124 agwStyle=AS_NOTIMEOUT | AS_CENTER_ON_SCREEN) |
124 |
|
125 |
125 |
126 def BackgroundInitialization(self): |
126 def BackgroundInitialization(self): |
127 self.InitI18n() |
127 self.InitI18n() |
128 self.CheckUpdates() |
128 self.CheckUpdates() |
129 self.LoadExtensions() |
129 self.LoadExtensions() |
189 self.frame.Show() |
189 self.frame.Show() |
190 |
190 |
191 def PreStart(self): |
191 def PreStart(self): |
192 self.ProcessCommandLineArgs() |
192 self.ProcessCommandLineArgs() |
193 self.CreateApplication() |
193 self.CreateApplication() |
194 |
194 |
195 def AppStart(self): |
195 def AppStart(self): |
196 try: |
196 try: |
197 self.BackgroundInitialization() |
197 self.BackgroundInitialization() |
198 self.CreateUI() |
198 self.CreateUI() |
199 self.CloseSplash() |
199 self.CloseSplash() |
200 self.ShowUI() |
200 self.ShowUI() |
201 # except (KeyboardInterrupt, SystemExit): |
201 # except (KeyboardInterrupt, SystemExit): |
202 # raise |
202 # raise |
203 except Exception: |
203 except Exception: |
204 self.handle_exception(*sys.exc_info(), exit = True) |
204 self.handle_exception(*sys.exc_info(), exit=True) |
205 |
205 |
206 def MainLoop(self): |
206 def MainLoop(self): |
207 self.app.MainLoop() |
207 self.app.MainLoop() |
208 |
208 |
209 def Start(self): |
209 def Start(self): |