[wxPython-users] Re: SetItemPyData() Clarification
Werner F. Bruhin
werner.bruhin at free.fr
Tue Dec 5 03:30:43 PST 2006
Hi Rich,
Rich Shepard wrote:
> On Mon, 4 Dec 2006, Brian Smith wrote:
>
>> Based on what you say about adding grandchildren and what I read in your
>> original question, I'm not sure if you need to use SetItemPyData() at
>> all. It sounds like you want something like this:
>>
>> for item in self.appData.polNat:
>> child = self.polTree.AppendItem( self.natID, item[0] )
>
> Brian,
>
> Yes! That was it.
>
> I want to attach the items, but have no associated data with each.
>
> Now, while on a roll, if I make child into childID[], will this
> assign a
> unique ID to each child so that one level more could be added to the
> tree?
>
> Right now I have:
>
> root
> |
> |->child
> |
> |->grandchild
>
> and I need to add one more level, potentially to each grandchild.
The new API doc shows:
TreeItemId AddRoot(self, text, image, selectedImage, data)
TreeItemId AppendItem(self, parent, text, image, selectedImage, data)
The return value when adding an item is the TreeItemId.
pseudo code:
root = treectrl.AddRoot(text, image, selectedImage, data)
for child in dbdatachild:
child = treectrl.AppendItem(root, text, image, selectedImage, data)
for grandchild in dbdatagrandchild:
grandchild = treectrl.AppendItem(child, text, image,
selectedImage, data)
for grandgrandchild in dbdatagrandchild:
grandgrandchild = treectrl.AppendItem(grandchild, text, image,
selectedImage, data)
or if you add later on:
child = treectrl.GetSelection()
for grandchild in dbdatagrandchild:
grandchild = treectrl.AppendItem(child, text, image,
selectedImage, data)
Werner
More information about the wxpython-users
mailing list