Launcher: ShowUI call moves from preStart to start. ShowUI() split into CreateUI() and ShowUI(). Start()'s arguments are passed to CreateUI()
authorEdouard Tisserant
Fri, 02 Feb 2018 11:12:03 +0100
changeset 1922 5353f4086a45
parent 1921 cf54939e6b0c
child 1923 65edbc03fdbf
Launcher: ShowUI call moves from preStart to start. ShowUI() split into CreateUI() and ShowUI(). Start()'s arguments are passed to CreateUI()
This is meant to allow customizations to pass own pre-instanciated controller to UI at startup.
Beremiz.py
--- a/Beremiz.py	Fri Feb 02 11:07:39 2018 +0100
+++ b/Beremiz.py	Fri Feb 02 11:12:03 2018 +0100
@@ -130,7 +130,6 @@
         self.LoadExtensions()
         self.ImportModules()
         self.InstallExceptionHandler()
-        self.ShowUI()
 
     def InitI18n(self):
         from util.misc import InstallLocalRessources
@@ -172,17 +171,18 @@
             self.splash.SetText(text=self.updateinfo)
 
     def ImportModules(self):
-        global BeremizIDE
         import BeremizIDE
+        self.frame_class = BeremizIDE.Beremiz
 
     def InstallExceptionHandler(self):
         import version
         import util.ExceptionHandler
         util.ExceptionHandler.AddExceptHook(version.app_version)
 
+    def CreateUI(self,**kwargs):
+        self.frame = self.frame_class(None, self.projectOpen, self.buildpath, **kwargs)
+
     def ShowUI(self):
-        import BeremizIDE
-        self.frame = BeremizIDE.Beremiz(None, self.projectOpen, self.buildpath)
         if self.splash:
             self.splash.Close()
         self.frame.Show()
@@ -196,8 +196,10 @@
     def MainLoop(self):
         self.app.MainLoop()
 
-    def Start(self):
+    def Start(self,**kwargs):
         self.PreStart()
+        self.CreateUI(**kwargs)
+        self.ShowUI()
         self.MainLoop()