Adding support for wxpython 2.4
authorlbessard
Wed, 24 Oct 2007 16:00:00 +0200
changeset 113 9eeaebd867aa
parent 112 317148fc1225
child 114 06454545e5d0
Adding support for wxpython 2.4
Dialogs.py
RessourceEditor.py
TextViewer.py
--- a/Dialogs.py	Wed Oct 24 15:59:46 2007 +0200
+++ b/Dialogs.py	Wed Oct 24 16:00:00 2007 +0200
@@ -41,6 +41,14 @@
 [CATEGORY, BLOCK] = range(2)
 
 class BlockPropertiesDialog(wx.Dialog):
+    
+    if wx.VERSION < (2, 6, 0):
+        def Bind(self, event, function, id = None):
+            if id is not None:
+                event(self, id, function)
+            else:
+                event(self, function)
+    
     def _init_coll_flexGridSizer1_Items(self, parent):
         parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
         parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
@@ -143,9 +151,12 @@
         setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
 
         self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
-        self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
-        
-        self.Bind(wx.EVT_PAINT, self.OnPaint)
+        if wx.VERSION >= (2, 5, 0):
+            self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
+            self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
+        else:
+            self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId())
+            wx.EVT_PAINT(self.Preview, self.OnPaint)
         
         self._init_sizers()
 
@@ -156,6 +167,7 @@
         self.Inputs.Enable(False)
         self.Block = None
         self.MinBlockSize = None
+        self.First = True
         
         self.PouNames = []
         self.PouElementNames = []
@@ -170,7 +182,10 @@
             if self.TypeTree.GetItemText(root) == name and same_inputs:
                 return root
             else:
-                item, root_cookie = self.TypeTree.GetFirstChild(root)
+                if wx.VERSION < (2, 6, 0):
+                    item, root_cookie = self.TypeTree.GetFirstChild(root, 0)
+                else:
+                    item, root_cookie = self.TypeTree.GetFirstChild(root)
                 while item.IsOk():
                     result = self.FindTreeItem(item, name, inputs)
                     if result:
@@ -326,7 +341,7 @@
                     self.Block = None
 
     def OnPaint(self, event):
-        if self.Block:
+        if self.Block is not None:
             self.RefreshPreview()
         event.Skip()
 
@@ -342,6 +357,14 @@
 ] = [wx.NewId() for _init_ctrls in range(10)]
 
 class VariablePropertiesDialog(wx.Dialog):
+    
+    if wx.VERSION < (2, 6, 0):
+        def Bind(self, event, function, id = None):
+            if id is not None:
+                event(self, id, function)
+            else:
+                event(self, function)
+    
     def _init_coll_flexGridSizer1_Items(self, parent):
         parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
         parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
@@ -451,8 +474,11 @@
 
         self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
 
-        self.Bind(wx.EVT_PAINT, self.OnPaint)
-
+        if wx.VERSION >= (2, 5, 0):
+            self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
+        else:
+            wx.EVT_PAINT(self.Preview, self.OnPaint)
+        
         self._init_sizers()
 
     def __init__(self, parent):
@@ -603,6 +629,14 @@
 ] = [wx.NewId() for _init_ctrls in range(9)]
 
 class ConnectionPropertiesDialog(wx.Dialog):
+    
+    if wx.VERSION < (2, 6, 0):
+        def Bind(self, event, function, id = None):
+            if id is not None:
+                event(self, id, function)
+            else:
+                event(self, function)
+    
     def _init_coll_flexGridSizer1_Items(self, parent):
         parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
         parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
@@ -699,7 +733,10 @@
 
         self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
         
-        self.Bind(wx.EVT_PAINT, self.OnPaint)
+        if wx.VERSION >= (2, 5, 0):
+            self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
+        else:
+            wx.EVT_PAINT(self.Preview, self.OnPaint)
         
         self._init_sizers()
 
@@ -775,6 +812,14 @@
 ] = [wx.NewId() for _init_ctrls in range(11)]
 
 class LDElementDialog(wx.Dialog):
+    
+    if wx.VERSION < (2, 6, 0):
+        def Bind(self, event, function, id = None):
+            if id is not None:
+                event(self, id, function)
+            else:
+                event(self, function)
+    
     def _init_coll_flexGridSizer1_Items(self, parent):
         parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
         parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
@@ -882,7 +927,10 @@
 
         self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
         
-        self.Bind(wx.EVT_PAINT, self.OnPaint)
+        if wx.VERSION >= (2, 5, 0):
+            self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
+        else:
+            wx.EVT_PAINT(self.Preview, self.OnPaint)
         
         self._init_sizers()
 
@@ -992,6 +1040,14 @@
 ] = [wx.NewId() for _init_ctrls in range(10)]
 
 class LDPowerRailDialog(wx.Dialog):
+    
+    if wx.VERSION < (2, 6, 0):
+        def Bind(self, event, function, id = None):
+            if id is not None:
+                event(self, id, function)
+            else:
+                event(self, function)
+    
     def _init_coll_flexGridSizer1_Items(self, parent):
         parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
         parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
@@ -1087,7 +1143,10 @@
 
         self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
         
-        self.Bind(wx.EVT_PAINT, self.OnPaint)
+        if wx.VERSION >= (2, 5, 0):
+            self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
+        else:
+            wx.EVT_PAINT(self.Preview, self.OnPaint)
         
         self._init_sizers()
 
@@ -1154,6 +1213,14 @@
 ] = [wx.NewId() for _init_ctrls in range(10)]
 
 class StepContentDialog(wx.Dialog):
+    
+    if wx.VERSION < (2, 6, 0):
+        def Bind(self, event, function, id = None):
+            if id is not None:
+                event(self, id, function)
+            else:
+                event(self, function)
+    
     def _init_coll_flexGridSizer1_Items(self, parent):
         parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
         parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
@@ -1254,10 +1321,13 @@
         setattr(self.Preview, "RefreshStepModel", lambda x:None)
 
         self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
-        self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
-        
-        self.Bind(wx.EVT_PAINT, self.OnPaint)
-
+        if wx.VERSION >= (2, 5, 0):
+            self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
+            self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
+        else:
+            self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId())
+            wx.EVT_PAINT(self.Preview, self.OnPaint)
+        
         self._init_sizers()
 
     def __init__(self, parent, initial = False):
@@ -1382,6 +1452,14 @@
 ] = [wx.NewId() for _init_ctrls in range(12)]
 
 class TransitionContentDialog(wx.Dialog):
+    
+    if wx.VERSION < (2, 6, 0):
+        def Bind(self, event, function, id = None):
+            if id is not None:
+                event(self, id, function)
+            else:
+                event(self, function)
+    
     def _init_coll_flexGridSizer1_Items(self, parent):
         parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
         parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
@@ -1500,9 +1578,12 @@
               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
 
         self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
-        self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
-        
-        self.Bind(wx.EVT_PAINT, self.OnPaint)
+        if wx.VERSION >= (2, 5, 0):
+            self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
+            self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
+        else:
+            self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId())
+            wx.EVT_PAINT(self.Preview, self.OnPaint)
         
         self._init_sizers()
 
@@ -1644,6 +1725,14 @@
 ] = [wx.NewId() for _init_ctrls in range(11)]
 
 class DivergenceCreateDialog(wx.Dialog):
+    
+    if wx.VERSION < (2, 6, 0):
+        def Bind(self, event, function, id = None):
+            if id is not None:
+                event(self, id, function)
+            else:
+                event(self, function)
+    
     def _init_coll_flexGridSizer1_Items(self, parent):
         parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
         parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
@@ -1754,7 +1843,10 @@
 
         self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
         
-        self.Bind(wx.EVT_PAINT, self.OnPaint)
+        if wx.VERSION >= (2, 5, 0):
+            self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
+        else:
+            wx.EVT_PAINT(self.Preview, self.OnPaint)
         
         self._init_sizers()
 
@@ -1985,6 +2077,14 @@
 ] = [wx.NewId() for _init_ctrls in range(7)]
 
 class ActionBlockDialog(wx.Dialog):
+    
+    if wx.VERSION < (2, 6, 0):
+        def Bind(self, event, function, id = None):
+            if id is not None:
+                event(self, id, function)
+            else:
+                event(self, function)
+    
     def _init_coll_flexGridSizer1_Items(self, parent):
         parent.AddSizer(self.TopSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
         parent.AddSizer(self.GridButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.LEFT|wx.RIGHT)
@@ -2064,8 +2164,11 @@
         self.Bind(wx.EVT_BUTTON, self.OnDownButton, id=ID_ACTIONBLOCKDIALOGDOWNBUTTON)
 
         self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
-        self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
-
+        if wx.VERSION >= (2, 5, 0):
+            self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
+        else:
+            self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId())
+        
         self._init_sizers()
 
     def __init__(self, parent):
@@ -2180,6 +2283,14 @@
 
 class StepNameDialog(wx.TextEntryDialog):
 
+    if wx.VERSION < (2, 6, 0):
+        def Bind(self, event, function, id = None):
+            if id is not None:
+                event(self, id, function)
+            else:
+                event(self, function)
+    
+
     def __init__(self, parent, message, caption = "Please enter text", defaultValue = "", 
                        style = wx.OK|wx.CANCEL|wx.CENTRE, pos = wx.DefaultPosition):
         wx.TextEntryDialog.__init__(self, parent, message, caption, defaultValue, style, pos)
@@ -2187,9 +2298,11 @@
         self.PouNames = []
         self.Variables = []
         self.StepNames = []
-        
-        self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetAffirmativeButton().GetId())
-        
+        if wx.VERSION >= (2, 5, 0):
+            self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetAffirmativeButton().GetId())
+        else:
+            self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId())
+    
     def OnOK(self, event):
         step_name = self.GetSizer().GetItem(1).GetWindow().GetValue()
         if step_name == "":
--- a/RessourceEditor.py	Wed Oct 24 15:59:46 2007 +0200
+++ b/RessourceEditor.py	Wed Oct 24 16:00:00 2007 +0200
@@ -209,6 +209,13 @@
 
 class ResourceEditor(wx.Panel):
     
+    if wx.VERSION < (2, 6, 0):
+        def Bind(self, event, function, id = None):
+            if id is not None:
+                event(self, id, function)
+            else:
+                event(self, function)
+    
     def _init_coll_InstancesSizer_Growables(self, parent):
         parent.AddGrowableCol(0)
         parent.AddGrowableRow(1)
@@ -291,8 +298,11 @@
               'Sans'))
         self.TasksGrid.SetLabelFont(wx.Font(10, 77, wx.NORMAL, wx.NORMAL,
               False, 'Sans'))
-        self.TasksGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnTasksGridCellChange)
-
+        if wx.VERSION >= (2, 5, 0):
+            self.TasksGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnTasksGridCellChange)
+        else:
+            wx.grid.EVT_GRID_CELL_CHANGE(self.TasksGrid, self.OnTasksGridCellChange)
+        
         self.AddTaskButton = wx.Button(id=ID_RESOURCEEDITORADDTASKBUTTON, label='Add Task',
               name='AddTaskButton', parent=self, pos=wx.Point(0, 0),
               size=wx.Size(102, 32), style=0)
@@ -324,8 +334,11 @@
               'Sans'))
         self.InstancesGrid.SetLabelFont(wx.Font(10, 77, wx.NORMAL, wx.NORMAL,
               False, 'Sans'))
-        self.InstancesGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnInstancesGridCellChange)
-
+        if wx.VERSION >= (2, 5, 0):
+            self.InstancesGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnInstancesGridCellChange)
+        else:
+            wx.grid.EVT_GRID_CELL_CHANGE(self.InstancesGrid, self.OnInstancesGridCellChange)
+        
         self.AddInstanceButton = wx.Button(id=ID_RESOURCEEDITORADDINSTANCEBUTTON, label='Add Instance',
               name='AddInstanceButton', parent=self, pos=wx.Point(0, 0),
               size=wx.Size(122, 32), style=0)
--- a/TextViewer.py	Wed Oct 24 15:59:46 2007 +0200
+++ b/TextViewer.py	Wed Oct 24 16:00:00 2007 +0200
@@ -91,6 +91,13 @@
 
 class TextViewer(wx.stc.StyledTextCtrl):
     
+    if wx.VERSION < (2, 6, 0):
+        def Bind(self, event, function, id = None):
+            if id is not None:
+                event(self, id, function)
+            else:
+                event(self, function)
+    
     def __init__(self, parent, window, controler):
         wx.stc.StyledTextCtrl.__init__(self, parent, ID_TEXTVIEWER, size=wx.Size(0, 0), style=0)