self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnActivate, self.tree)
self.tree.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDClick)
self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnActivate, self.tree)
self.tree.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDClick)
pt = event.GetPosition();
item, flags = self.tree.HitTest(pt)
pt = event.GetPosition();
item, flags = self.tree.HitTest(pt)
- self.log.WriteText("OnRightClick: %s, %s, %s\n" %
- (self.tree.GetItemText(item), type(item), item.__class__))
- self.tree.SelectItem(item)
+ if item:
+ self.log.WriteText("OnRightClick: %s, %s, %s\n" %
+ (self.tree.GetItemText(item), type(item), item.__class__))
+ self.tree.SelectItem(item)
def OnRightUp(self, event):
pt = event.GetPosition();
item, flags = self.tree.HitTest(pt)
def OnRightUp(self, event):
pt = event.GetPosition();
item, flags = self.tree.HitTest(pt)
- self.log.WriteText("OnRightUp: %s (manually starting label edit)\n"
- % self.tree.GetItemText(item))
- self.tree.EditLabel(item)
+ if item:
+ self.log.WriteText("OnRightUp: %s (manually starting label edit)\n"
+ % self.tree.GetItemText(item))
+ self.tree.EditLabel(item)
def OnBeginEdit(self, event):
self.log.WriteText("OnBeginEdit\n")
# show how to prevent edit...
def OnBeginEdit(self, event):
self.log.WriteText("OnBeginEdit\n")
# show how to prevent edit...
def OnLeftDClick(self, event):
pt = event.GetPosition();
item, flags = self.tree.HitTest(pt)
def OnLeftDClick(self, event):
pt = event.GetPosition();
item, flags = self.tree.HitTest(pt)
- self.log.WriteText("OnLeftDClick: %s\n" % self.tree.GetItemText(item))
- parent = self.tree.GetItemParent(item)
- self.tree.SortChildren(parent)
+ if item:
+ self.log.WriteText("OnLeftDClick: %s\n" % self.tree.GetItemText(item))
+ parent = self.tree.GetItemParent(item)
+ if parent.IsOk():
+ self.tree.SortChildren(parent)
def OnSelChanged(self, event):
self.item = event.GetItem()
def OnSelChanged(self, event):
self.item = event.GetItem()
- self.log.WriteText("OnSelChanged: %s\n" % self.tree.GetItemText(self.item))
- if wx.Platform == '__WXMSW__':
- self.log.WriteText("BoundingRect: %s\n" %
- self.tree.GetBoundingRect(self.item, True))
- #items = self.tree.GetSelections()
- #print map(self.tree.GetItemText, items)
+ if self.item:
+ self.log.WriteText("OnSelChanged: %s\n" % self.tree.GetItemText(self.item))
+ if wx.Platform == '__WXMSW__':
+ self.log.WriteText("BoundingRect: %s\n" %
+ self.tree.GetBoundingRect(self.item, True))
+ #items = self.tree.GetSelections()
+ #print map(self.tree.GetItemText, items)