From: Jussi S. <jus...@pp...> - 2006-09-17 13:12:35
|
This is for Ade to answer the question on Sep 11, 2006 No-one has answered your question. I don't know if it is because they thought you should be able to figure out yourself. After investigating your problem, I at least think so because it took me under a hour from the problem to the solution and I've never used the treecontrol nor looked at its demos nor the souce code nor the documentation. Here's what I did and what I think you should have done also: 1. I looked at the Pythoncard treecontrol demo and its source code. The events handled by PythonCard are listed at the beginning of the minimaltree code 2. I looked at the wxPython demo finding the treecontrol demo, running it and browsing its source code. I found out that the event generated by clicking the item text is OnSelChanged. 3. But your original headache was how to find the path to the root. Well I had the third and last help item left: wxWidgets documentation. There I browsed the wxTreeCtrl documentation looking for something with Parent in it. Found GetParent with a note to use GetItemParent instead. 4. Copied the minimaltree example to my own directory and started modifying and debuggin it to get what I/you wanted. Copied the on_tree_itemExpanding method and modified it to become (after 3-4 iterations): def on_tree_selectionChanged(self, event): tree = self.components.tree item=event.item #obj = int(tree.getItemText(item)) #print 'selChanged', obj if item != self.root: listToRoot = [] while item: listToRoot.append(tree.getItemText(item)) item = tree.GetItemParent(item) #print item listToRoot.reverse() print '_'.join(listToRoot) event.skip() I think this is near enough the thing you wanted, isn't it? |