First of all, happy Xmas to all of those who celebrate it, and all the best!
And now let's get down to business... is there a way to map all of
TreeCtrls' nodes to some other data structure, let's say a list? I
tried to do it by using a dictionary, like so in
wx.TreeCtrl.__init__():
for i in range(5):
tmpId = self.AppendItem(self.treeRoot, str(i))
self.items[tmpId] = ['node', i]
Here, self.items is a dictionary, it's keys should be wx.TreeItemIds'
and every key should point to a simple list. When I print self.items
dictionary, it seems OK.
The problem is, how to lookup items in that dictionary? I tried using
this binding and accompanying function:
self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged, self.tree)
def OnSelChanged(self, event):
item = event.GetItem()
print self.items[item].
event.Skip()
But I get a KeyError (no matter what node gets selected). What's even
more puzzling (at least to me), is that when I print those
event.GetItem() - they all look the same, no matter what node I
click?!
So, how to uniquely map nodes to some other data structure? I can't
use node labels, because they aren't unique. I've attached a simple
(35 lines) script that demonstrates my problem. It should print 'Found
it', for every node click, but instead it remains silent.
Thanks in advance...
__test_treectrl.py (1.16 KB)
···
--
Karlo Lozovina -- Mosor
"Parce mihi domine quia Dalmata sum."