fix issues in PLCOpenEditor with moving from wxWidgets 2.8 to 3.0
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Tue, 13 Sep 2016 21:42:11 +0300
changeset 1533 aca8f43483e9
parent 1532 a191e137a5bb
child 1535 b3c43aa29d94
fix issues in PLCOpenEditor with moving from wxWidgets 2.8 to 3.0

1)
./PLCOpenEditor.py:63: wxPyDeprecationWarning: Using deprecated class PySimpleApp.
app = wx.PySimpleApp()

2)
./PLCOpenEditor.py:475: wxPyDeprecationWarning: Call to deprecated item.
wx.InitAllImageHandlers()

3)
Traceback (most recent call last):
File "./PLCOpenEditor.py", line 480, in <module>
frame = PLCOpenEditor(None, fileOpen=fileOpen)
File "./PLCOpenEditor.py", line 163, in __init__
IDEFrame.__init__(self, parent)
File "/tmp/f/beremiz/IDEFrame.py", line 657, in __init__
self._init_ctrls(parent)
File "/tmp/f/beremiz/IDEFrame.py", line 485, in _init_ctrls
self._init_icon(prnt)
File "/tmp/f/beremiz/IDEFrame.py", line 476, in _init_icon
if self.icon:
AttributeError: 'PLCOpenEditor' object has no attribute 'icon'
PLCOpenEditor.py
--- a/PLCOpenEditor.py	Mon Sep 12 16:49:24 2016 +0300
+++ b/PLCOpenEditor.py	Tue Sep 13 21:42:11 2016 +0300
@@ -60,7 +60,11 @@
 
     # Create wxApp (Need to create App before internationalization because of
     # Windows)
-    app = wx.PySimpleApp()
+    if wx.VERSION >= (3, 0, 0):
+        app = wx.App()
+    else:
+        app = wx.PySimpleApp()
+
 
     from util.misc import InstallLocalRessources
     InstallLocalRessources(beremiz_dir)
@@ -160,6 +164,7 @@
     #  @param fileOpen The filepath to open if no controler defined (default: None).
     #  @param debug The filepath to open if no controler defined (default: False).
     def __init__(self, parent, fileOpen = None):
+        self.icon = wx.Icon(os.path.join(beremiz_dir, "images", "poe.ico"), wx.BITMAP_TYPE_ICO)
         IDEFrame.__init__(self, parent)
 
         result = None
@@ -178,7 +183,7 @@
                 self._Refresh(PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE)
 
         # Define PLCOpenEditor icon
-        self.SetIcon(wx.Icon(os.path.join(beremiz_dir, "images", "poe.ico"),wx.BITMAP_TYPE_ICO))
+        self.SetIcon(self.icon)
 
         self.Bind(wx.EVT_CLOSE, self.OnCloseFrame)
 
@@ -472,7 +477,8 @@
     sys.excepthook = handle_exception
 
 if __name__ == '__main__':
-    wx.InitAllImageHandlers()
+    if wx.VERSION < (3, 0, 0):
+        wx.InitAllImageHandlers()
 
     # Install a exception handle for bug reports
     AddExceptHook(os.getcwd(),__version__)