Beremiz.py
changeset 1475 de4ee16f7c6c
parent 1451 94e620cbd9de
child 1483 004f9c52f7d8
--- a/Beremiz.py	Sat Dec 06 19:31:51 2014 +0000
+++ b/Beremiz.py	Wed Oct 21 15:00:32 2015 +0100
@@ -25,19 +25,23 @@
 
 updateinfo_url = None
 
-import os, sys, getopt, wx
+import os, sys, getopt
 import __builtin__
-from wx.lib.agw.advancedsplash import AdvancedSplash
 import tempfile
 import shutil
 import random
 import time
 from types import ListType
 
-CWD = os.path.split(os.path.realpath(__file__))[0]
+beremiz_dir = os.path.dirname(os.path.realpath(__file__))
+
+import wxversion
+wxversion.select('2.8')
+import wx
+from wx.lib.agw.advancedsplash import AdvancedSplash
 
 def Bpath(*args):
-    return os.path.join(CWD,*args)
+    return os.path.join(beremiz_dir,*args)
 
 if __name__ == '__main__':
     def usage():
@@ -111,7 +115,7 @@
         wx.Yield()
 
     from util.misc import InstallLocalRessources
-    InstallLocalRessources(CWD)
+    InstallLocalRessources(beremiz_dir)
 
     # Load extensions
     for extfilename in extensions:
@@ -634,6 +638,13 @@
         else:
             return IDEFrame.LoadTab(self, notebook, page_infos)
 
+    # Strange hack required by WAMP connector, using twisted.
+    # Twisted reactor needs to be stopped only before quit,
+    # since it cannot be restarted
+    ToDoBeforeQuit = []
+    def AddToDoBeforeQuit(self, Thing):
+        self.ToDoBeforeQuit.append(Thing)
+
     def OnCloseFrame(self, event):
         for evt_type in [wx.EVT_SET_FOCUS,
                          wx.EVT_KILL_FOCUS,
@@ -646,6 +657,10 @@
 
             self.SaveLastState()
 
+            for Thing in self.ToDoBeforeQuit :
+                Thing()
+            self.ToDoBeforeQuit = []
+
             event.Skip()
         else:
             event.Veto()