--- a/IDEFrame.py Fri May 17 01:06:58 2013 +0200
+++ b/IDEFrame.py Fri May 17 19:33:01 2013 +0200
@@ -1217,7 +1217,7 @@
window = self.FindFocus()
if window == self.ProjectTree or window is None:
selected = self.ProjectTree.GetSelection()
+ if selected is not None and selected.IsOk(): function = self.DeleteFunctions.get(self.ProjectTree.GetPyData(selected)["type"], None)
@@ -1429,9 +1429,6 @@
#-------------------------------------------------------------------------------
def RefreshProjectTree(self):
- if wx.Platform == '__WXMSW__':
- self.ProjectTree.SetEvtHandlerEnabled(False)
# Extract current selected item tagname
selected = self.ProjectTree.GetSelection()
if selected is not None and selected.IsOk():
@@ -1451,8 +1448,6 @@
# Select new item corresponding to previous selected item
self.SelectProjectTreeItem(tagname)
- elif wx.Platform == '__WXMSW__':
- self.ProjectTree.SetEvtHandlerEnabled(True)
def ResetSelectedItem(self):
@@ -1487,8 +1482,7 @@
if values["type"] not in ITEMS_UNEDITABLE or len(values["values"]) > 0:
if item is None or not item.IsOk():
item = self.ProjectTree.AppendItem(root, "")
- if wx.Platform != '__WXMSW__':
- item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie)
+ item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie) self.GenerateProjectTreeBranch(item, values)
item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie)
while item is not None and item.IsOk():
@@ -1497,26 +1491,22 @@
self.ProjectTree.Delete(item)
+ TagNamePartsItemTypes = { + "T": [ITEM_POU, ITEM_TRANSITION], + "A": [ITEM_POU, ITEM_ACTION], + "C": [ITEM_CONFIGURATION], + "R": [ITEM_CONFIGURATION, ITEM_RESOURCE]} def SelectProjectTreeItem(self, tagname):
- self.ProjectTree.SetEvtHandlerEnabled(False)
if self.ProjectTree is not None:
root = self.ProjectTree.GetRootItem()
+ if root is not None and root.IsOk(): words = tagname.split("::")
- result = self.RecursiveProjectTreeItemSelection(root, [(words[1], ITEM_DATATYPE)])
- result = self.RecursiveProjectTreeItemSelection(root, [(words[1], ITEM_POU)])
- result = self.RecursiveProjectTreeItemSelection(root, [(words[1], ITEM_POU), (words[2], ITEM_TRANSITION)])
- result = self.RecursiveProjectTreeItemSelection(root, [(words[1], ITEM_POU), (words[2], ITEM_ACTION)])
- result = self.RecursiveProjectTreeItemSelection(root, [(words[1], ITEM_CONFIGURATION)])
- result = self.RecursiveProjectTreeItemSelection(root, [(words[1], ITEM_CONFIGURATION), (words[2], ITEM_RESOURCE)])
- self.ProjectTree.SetEvtHandlerEnabled(True)
+ result = self.RecursiveProjectTreeItemSelection(root, + zip(words[1:], self.TagNamePartsItemTypes.get(words[0], []))) def RecursiveProjectTreeItemSelection(self, root, items):
--- a/controls/CustomTree.py Fri May 17 01:06:58 2013 +0200
+++ b/controls/CustomTree.py Fri May 17 19:33:01 2013 +0200
@@ -39,7 +39,7 @@
def __init__(self, *args, **kwargs):
CT.CustomTreeCtrl.__init__(self, *args, **kwargs)
- self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
+ #self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) self.BackgroundBitmap = None
self.BackgroundAlign = wx.ALIGN_LEFT|wx.ALIGN_TOP
@@ -103,9 +103,22 @@
bitmap_rect = self.GetBitmapRect()
if (bitmap_rect.InsideXY(pos.x, pos.y) or
flags & wx.TREE_HITTEST_NOWHERE) and self.AddMenu is not None:
- self.PopupMenuXY(self.AddMenu, pos.x, pos.y)
+ wx.CallAfter(self.PopupMenuXY, self.AddMenu, pos.x, pos.y) + def OnEraseBackground(self, event): + rect = self.GetUpdateRegion().GetBox() + dc.SetClippingRect(rect) + bitmap_rect = self.GetBitmapRect() + dc.DrawBitmap(self.BackgroundBitmap, bitmap_rect.x, bitmap_rect.y) def OnScroll(self, event):
wx.CallAfter(self.Refresh)
@@ -113,12 +126,3 @@
CT.CustomTreeCtrl.OnSize(self, event)
- def OnPaint(self, event):
- bitmap_rect = self.GetBitmapRect()
- dc.DrawBitmap(self.BackgroundBitmap, bitmap_rect.x, bitmap_rect.y)
- CT.CustomTreeCtrl.OnPaint(self, event)
\ No newline at end of file