fix problem running PLCOpenEditor
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Fri, 25 Aug 2017 12:23:45 +0300
changeset 1791 3216ed1ba1f7
parent 1790 47fc06c13b37
child 1792 4d1de8b0183f
fix problem running PLCOpenEditor

$ ./PLCOpenEditor.py
../src/common/stdpbase.cpp(62): assert "traits" failed in Get(): create wxApp before calling this

Regression was introduced by '3311eea' (clean-up: fix PEP8 E402 module level import not at top of file)
PLCOpenEditor.py
--- a/PLCOpenEditor.py	Fri Aug 25 12:01:23 2017 +0300
+++ b/PLCOpenEditor.py	Fri Aug 25 12:23:45 2017 +0300
@@ -33,25 +33,6 @@
 import version
 import util.paths as paths
 
-from docutil import *
-from IDEFrame import IDEFrame, AppendMenu
-from IDEFrame import \
-    TITLE, \
-    EDITORTOOLBAR, \
-    FILEMENU, \
-    EDITMENU, \
-    DISPLAYMENU, \
-    PROJECTTREE, \
-    POUINSTANCEVARIABLESPANEL, \
-    LIBRARYTREE, \
-    PAGETITLES
-
-from IDEFrame import EncodeFileSystemPath, DecodeFileSystemPath
-from editors.Viewer import Viewer
-from PLCControler import PLCControler
-from dialogs import ProjectDialog
-from dialogs.AboutDialog import ShowAboutDialog
-
 
 beremiz_dir = paths.AbsDir(__file__)
 
@@ -96,6 +77,27 @@
     from util.misc import InstallLocalRessources
     InstallLocalRessources(beremiz_dir)
 
+    # these imports require wx.GetApp to return
+    # a valid application instance
+    from docutil import *
+    from IDEFrame import IDEFrame, AppendMenu
+    from IDEFrame import \
+        TITLE, \
+        EDITORTOOLBAR, \
+        FILEMENU, \
+        EDITMENU, \
+        DISPLAYMENU, \
+        PROJECTTREE, \
+        POUINSTANCEVARIABLESPANEL, \
+        LIBRARYTREE, \
+        PAGETITLES
+
+    from IDEFrame import EncodeFileSystemPath, DecodeFileSystemPath
+    from editors.Viewer import Viewer
+    from PLCControler import PLCControler
+    from dialogs import ProjectDialog
+    from dialogs.AboutDialog import ShowAboutDialog
+
 
 # -------------------------------------------------------------------------------
 #                            PLCOpenEditor Main Class