53 def Bpath(self, *args): |
52 def Bpath(self, *args): |
54 return os.path.join(self.app_dir, *args) |
53 return os.path.join(self.app_dir, *args) |
55 |
54 |
56 def ShowSplashScreen(self): |
55 def ShowSplashScreen(self): |
57 bmp = wx.Image(self.splashPath).ConvertToBitmap() |
56 bmp = wx.Image(self.splashPath).ConvertToBitmap() |
58 self.splash = AdvancedSplash(None, bitmap=bmp) |
57 self.splash = AdvancedSplash(None, bitmap=bmp, agwStyle=AS_NOTIMEOUT | AS_CENTER_ON_SCREEN) |
59 |
58 |
60 # process all events |
|
61 # even the events generated by splash themself during showing |
|
62 if wx.Platform == '__WXMSW__': |
|
63 self.splash.Show() |
|
64 self.splash.ProcessEvent(wx.PaintEvent()) |
|
65 else: |
|
66 for dummy in range(0, 30): |
|
67 wx.Yield() |
|
68 time.sleep(0.01) |
|
69 |
59 |
70 def Usage(self): |
60 def Usage(self): |
71 print("Usage:") |
61 print("Usage:") |
72 print("%s [Options] [Projectpath] [Buildpath]" % sys.argv[0]) |
62 print("%s [Options] [Projectpath] [Buildpath]" % sys.argv[0]) |
73 print("") |
63 print("") |
113 elif len(args) == 2: |
103 elif len(args) == 2: |
114 self.projectOpen = args[0] |
104 self.projectOpen = args[0] |
115 self.buildpath = args[1] |
105 self.buildpath = args[1] |
116 |
106 |
117 def CreateApplication(self): |
107 def CreateApplication(self): |
118 if wx.VERSION >= (3, 0, 0): |
108 |
119 self.app = wx.App(redirect=self.debug) |
109 BeremizAppType = wx.App if wx.VERSION >= (3, 0, 0) else wx.PySimpleApp |
120 else: |
110 class BeremizApp(BeremizAppType): |
121 self.app = wx.PySimpleApp(redirect=self.debug) |
111 def OnInit(_self): |
122 |
112 self.ShowSplashScreen() |
|
113 wx.CallAfter(self.AppStart) |
|
114 return True |
|
115 |
|
116 self.app = BeremizApp(redirect=self.debug) |
123 self.app.SetAppName('beremiz') |
117 self.app.SetAppName('beremiz') |
124 if wx.VERSION < (3, 0, 0): |
118 if wx.VERSION < (3, 0, 0): |
125 wx.InitAllImageHandlers() |
119 wx.InitAllImageHandlers() |
126 |
120 |
127 def BackgroundInitialization(self): |
121 def BackgroundInitialization(self): |
128 self.InitI18n() |
122 self.InitI18n() |
129 self.CheckUpdates() |
123 self.CheckUpdates() |
130 self.LoadExtensions() |
124 self.LoadExtensions() |
131 self.ImportModules() |
125 self.ImportModules() |
132 self.InstallExceptionHandler() |
|
133 |
126 |
134 def InitI18n(self): |
127 def InitI18n(self): |
135 from util.misc import InstallLocalRessources |
128 from util.misc import InstallLocalRessources |
136 InstallLocalRessources(self.app_dir) |
129 InstallLocalRessources(self.app_dir) |
137 |
130 |
176 setattr(self, modname, mod) |
169 setattr(self, modname, mod) |
177 |
170 |
178 def InstallExceptionHandler(self): |
171 def InstallExceptionHandler(self): |
179 import version |
172 import version |
180 import util.ExceptionHandler |
173 import util.ExceptionHandler |
181 util.ExceptionHandler.AddExceptHook(version.app_version) |
174 self.handle_exception = util.ExceptionHandler.AddExceptHook(version.app_version) |
182 |
175 |
183 def CreateUI(self): |
176 def CreateUI(self): |
184 self.frame = self.BeremizIDE.Beremiz(None, self.projectOpen, self.buildpath) |
177 self.frame = self.BeremizIDE.Beremiz(None, self.projectOpen, self.buildpath) |
185 |
178 |
186 def CloseSplash(self): |
179 def CloseSplash(self): |
191 self.frame.Show() |
184 self.frame.Show() |
192 |
185 |
193 def PreStart(self): |
186 def PreStart(self): |
194 self.ProcessCommandLineArgs() |
187 self.ProcessCommandLineArgs() |
195 self.CreateApplication() |
188 self.CreateApplication() |
196 self.ShowSplashScreen() |
189 |
197 self.BackgroundInitialization() |
190 def AppStart(self): |
198 self.CreateUI() |
191 try: |
199 self.CloseSplash() |
192 self.BackgroundInitialization() |
|
193 self.CreateUI() |
|
194 self.CloseSplash() |
|
195 self.ShowUI() |
|
196 # except (KeyboardInterrupt, SystemExit): |
|
197 # raise |
|
198 except Exception: |
|
199 self.handle_exception(*sys.exc_info(), exit = True) |
200 |
200 |
201 def MainLoop(self): |
201 def MainLoop(self): |
202 self.app.MainLoop() |
202 self.app.MainLoop() |
203 |
203 |
204 def Start(self): |
204 def Start(self): |
205 self.PreStart() |
205 self.PreStart() |
206 self.ShowUI() |
206 self.InstallExceptionHandler() |
207 self.MainLoop() |
207 self.MainLoop() |
208 |
208 |
209 |
209 |
210 if __name__ == '__main__': |
210 if __name__ == '__main__': |
211 beremiz = BeremizIDELauncher() |
211 beremiz = BeremizIDELauncher() |