Fixed bug when selecting item in ProjectTree on Linux
authorLaurent Bessard
Fri, 10 May 2013 10:25:35 +0200
changeset 1112 ff3fcad17b47
parent 1111 ee1a8c961f11
child 1113 16e5b6abd91c
Fixed bug when selecting item in ProjectTree on Linux
IDEFrame.py
--- a/IDEFrame.py	Fri May 10 10:24:59 2013 +0200
+++ b/IDEFrame.py	Fri May 10 10:25:35 2013 +0200
@@ -1421,10 +1421,11 @@
 #-------------------------------------------------------------------------------
 
     def RefreshProjectTree(self):
-        # Disconnect event when selection in treectrl changed
-        self.Unbind(wx.EVT_TREE_SEL_CHANGED, 
-                    id=ID_PLCOPENEDITORPROJECTTREE)
-    
+        if wx.Platform == '__WXMSW__':
+            # Disconnect event when selection in treectrl changed
+            self.Unbind(wx.EVT_TREE_SEL_CHANGED, 
+                        id=ID_PLCOPENEDITORPROJECTTREE)
+        
         # Extract current selected item tagname
         selected = self.ProjectTree.GetSelection()
         if selected is not None and selected.IsOk():
@@ -1444,12 +1445,13 @@
         # Select new item corresponding to previous selected item
         if tagname is not None:
             wx.CallAfter(self.SelectProjectTreeItem, tagname)
-    
-        # Reconnect event when selection in treectrl changed
-        wx.CallAfter(self.Bind, 
-            wx.EVT_TREE_SEL_CHANGED, 
-            self.OnProjectTreeItemSelected,
-            id=ID_PLCOPENEDITORPROJECTTREE)
+        
+        if wx.Platform == '__WXMSW__':
+            # Reconnect event when selection in treectrl changed
+            wx.CallAfter(self.Bind, 
+                wx.EVT_TREE_SEL_CHANGED, 
+                self.OnProjectTreeItemSelected,
+                id=ID_PLCOPENEDITORPROJECTTREE)
 
     def ResetSelectedItem(self):
         self.SelectedItem = None
@@ -1680,13 +1682,14 @@
             event.Skip()
     
     def ProjectTreeItemSelect(self, select_item):
-        name = self.ProjectTree.GetItemText(select_item)
-        item_infos = self.ProjectTree.GetPyData(select_item)
-        if item_infos["type"] in [ITEM_DATATYPE, ITEM_POU,
-                                  ITEM_CONFIGURATION, ITEM_RESOURCE,
-                                  ITEM_TRANSITION, ITEM_ACTION]:
-            self.EditProjectElement(item_infos["type"], item_infos["tagname"], True)
-            self.PouInstanceVariablesPanel.SetPouType(item_infos["tagname"])
+        if select_item.IsOk():
+            name = self.ProjectTree.GetItemText(select_item)
+            item_infos = self.ProjectTree.GetPyData(select_item)
+            if item_infos["type"] in [ITEM_DATATYPE, ITEM_POU,
+                                      ITEM_CONFIGURATION, ITEM_RESOURCE,
+                                      ITEM_TRANSITION, ITEM_ACTION]:
+                self.EditProjectElement(item_infos["type"], item_infos["tagname"], True)
+                self.PouInstanceVariablesPanel.SetPouType(item_infos["tagname"])
         
     def OnProjectTreeLeftUp(self, event):
         if self.SelectedItem is not None: