IDEFrame.py
changeset 1112 ff3fcad17b47
parent 1106 843d181f73b4
child 1129 189b49723f9f
equal deleted inserted replaced
1111:ee1a8c961f11 1112:ff3fcad17b47
  1419 #-------------------------------------------------------------------------------
  1419 #-------------------------------------------------------------------------------
  1420 #                         Types Tree Management Functions
  1420 #                         Types Tree Management Functions
  1421 #-------------------------------------------------------------------------------
  1421 #-------------------------------------------------------------------------------
  1422 
  1422 
  1423     def RefreshProjectTree(self):
  1423     def RefreshProjectTree(self):
  1424         # Disconnect event when selection in treectrl changed
  1424         if wx.Platform == '__WXMSW__':
  1425         self.Unbind(wx.EVT_TREE_SEL_CHANGED, 
  1425             # Disconnect event when selection in treectrl changed
  1426                     id=ID_PLCOPENEDITORPROJECTTREE)
  1426             self.Unbind(wx.EVT_TREE_SEL_CHANGED, 
  1427     
  1427                         id=ID_PLCOPENEDITORPROJECTTREE)
       
  1428         
  1428         # Extract current selected item tagname
  1429         # Extract current selected item tagname
  1429         selected = self.ProjectTree.GetSelection()
  1430         selected = self.ProjectTree.GetSelection()
  1430         if selected is not None and selected.IsOk():
  1431         if selected is not None and selected.IsOk():
  1431             item_infos = self.ProjectTree.GetPyData(selected)
  1432             item_infos = self.ProjectTree.GetPyData(selected)
  1432             tagname = item_infos.get("tagname", None)
  1433             tagname = item_infos.get("tagname", None)
  1442         self.ProjectTree.Expand(root)
  1443         self.ProjectTree.Expand(root)
  1443         
  1444         
  1444         # Select new item corresponding to previous selected item
  1445         # Select new item corresponding to previous selected item
  1445         if tagname is not None:
  1446         if tagname is not None:
  1446             wx.CallAfter(self.SelectProjectTreeItem, tagname)
  1447             wx.CallAfter(self.SelectProjectTreeItem, tagname)
  1447     
  1448         
  1448         # Reconnect event when selection in treectrl changed
  1449         if wx.Platform == '__WXMSW__':
  1449         wx.CallAfter(self.Bind, 
  1450             # Reconnect event when selection in treectrl changed
  1450             wx.EVT_TREE_SEL_CHANGED, 
  1451             wx.CallAfter(self.Bind, 
  1451             self.OnProjectTreeItemSelected,
  1452                 wx.EVT_TREE_SEL_CHANGED, 
  1452             id=ID_PLCOPENEDITORPROJECTTREE)
  1453                 self.OnProjectTreeItemSelected,
       
  1454                 id=ID_PLCOPENEDITORPROJECTTREE)
  1453 
  1455 
  1454     def ResetSelectedItem(self):
  1456     def ResetSelectedItem(self):
  1455         self.SelectedItem = None
  1457         self.SelectedItem = None
  1456 
  1458 
  1457     def GenerateProjectTreeBranch(self, root, infos):
  1459     def GenerateProjectTreeBranch(self, root, infos):
  1678                                     ITEM_TRANSITION, ITEM_ACTION]:
  1680                                     ITEM_TRANSITION, ITEM_ACTION]:
  1679                 self.EditProjectElement(item_infos["type"], item_infos["tagname"])
  1681                 self.EditProjectElement(item_infos["type"], item_infos["tagname"])
  1680             event.Skip()
  1682             event.Skip()
  1681     
  1683     
  1682     def ProjectTreeItemSelect(self, select_item):
  1684     def ProjectTreeItemSelect(self, select_item):
  1683         name = self.ProjectTree.GetItemText(select_item)
  1685         if select_item.IsOk():
  1684         item_infos = self.ProjectTree.GetPyData(select_item)
  1686             name = self.ProjectTree.GetItemText(select_item)
  1685         if item_infos["type"] in [ITEM_DATATYPE, ITEM_POU,
  1687             item_infos = self.ProjectTree.GetPyData(select_item)
  1686                                   ITEM_CONFIGURATION, ITEM_RESOURCE,
  1688             if item_infos["type"] in [ITEM_DATATYPE, ITEM_POU,
  1687                                   ITEM_TRANSITION, ITEM_ACTION]:
  1689                                       ITEM_CONFIGURATION, ITEM_RESOURCE,
  1688             self.EditProjectElement(item_infos["type"], item_infos["tagname"], True)
  1690                                       ITEM_TRANSITION, ITEM_ACTION]:
  1689             self.PouInstanceVariablesPanel.SetPouType(item_infos["tagname"])
  1691                 self.EditProjectElement(item_infos["type"], item_infos["tagname"], True)
       
  1692                 self.PouInstanceVariablesPanel.SetPouType(item_infos["tagname"])
  1690         
  1693         
  1691     def OnProjectTreeLeftUp(self, event):
  1694     def OnProjectTreeLeftUp(self, event):
  1692         if self.SelectedItem is not None:
  1695         if self.SelectedItem is not None:
  1693             self.ProjectTree.SelectItem(self.SelectedItem)
  1696             self.ProjectTree.SelectItem(self.SelectedItem)
  1694             self.ProjectTreeItemSelect(self.SelectedItem)
  1697             self.ProjectTreeItemSelect(self.SelectedItem)