--- a/PLCOpenEditor.py Fri Sep 15 20:28:54 2017 +0300
+++ b/PLCOpenEditor.py Fri Sep 15 20:30:24 2017 +0300
@@ -32,69 +32,23 @@
import util.paths as paths
import util.ExceptionHandler
-beremiz_dir = paths.AbsDir(__file__)
-if __name__ == '__main__':
- # Usage message displayed when help request or when error detected in
- print "\nUsage of PLCOpenEditor.py :"
- print "\n %s [Filepath]\n" % sys.argv[0]
- # Parse options given to PLCOpenEditor in command line
- opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])
- except getopt.GetoptError:
- # print help information and exit:
- # Extract if help has been requested
- if o in ("-h", "--help"):
- # Extract the optional filename to open
- # Create wxApp (Need to create App before internationalization because of
- if wx.VERSION >= (3, 0, 0):
- from util.misc import InstallLocalRessources
- InstallLocalRessources(beremiz_dir)
- # these imports require wx.GetApp to return
- # a valid application instance
- from IDEFrame import IDEFrame, AppendMenu
- POUINSTANCEVARIABLESPANEL, \
- from IDEFrame import EncodeFileSystemPath, DecodeFileSystemPath
- from editors.Viewer import Viewer
- from PLCControler import PLCControler
- from dialogs import ProjectDialog
- from dialogs.AboutDialog import ShowAboutDialog
+from IDEFrame import IDEFrame, AppendMenu + POUINSTANCEVARIABLESPANEL, \ +from IDEFrame import EncodeFileSystemPath, DecodeFileSystemPath +from editors.Viewer import Viewer +from PLCControler import PLCControler +from dialogs import ProjectDialog +from dialogs.AboutDialog import ShowAboutDialog +from util.misc import InstallLocalRessources # -------------------------------------------------------------------------------
@@ -107,6 +61,9 @@
] = [wx.NewId() for _init_coll_FileMenu_Items in range(1)]
+beremiz_dir = paths.AbsDir(__file__) class PLCOpenEditor(IDEFrame):
# Compatibility function for wx versions < 2.6
@@ -414,14 +371,50 @@
-if __name__ == '__main__':
- if wx.VERSION < (3, 0, 0):
- wx.InitAllImageHandlers()
+class PLCOpenEditorApp(wx.App): + print "\nUsage of PLCOpenEditor.py :" + print "\n %s [Filepath]\n" % sys.argv[0] + def ParseCommandLine(self): + # Parse options given to PLCOpenEditor in command line + opts, args = getopt.getopt(sys.argv[1:], "h", ["help"]) + except getopt.GetoptError: + # print help information and exit: + # Extract if help has been requested + if o in ("-h", "--help"): - # Install a exception handle for bug reports
- util.ExceptionHandler.AddExceptHook(version.app_version)
+ # Extract the optional filename to open + self.fileOpen = args[0] - frame = PLCOpenEditor(None, fileOpen=fileOpen)
+ self.ParseCommandLine() + InstallLocalRessources(beremiz_dir) + if wx.VERSION < (3, 0, 0): + wx.InitAllImageHandlers() + util.ExceptionHandler.AddExceptHook(version.app_version) + self.frame = PLCOpenEditor(None, fileOpen=self.fileOpen)
+if __name__ == '__main__': + app = PLCOpenEditorApp()