[wxPython-users] identify/track an item in a TreeCtrl

Pan Xingzhi vengeance.storm at gmail.com
Mon Dec 3 03:23:45 PST 2007


Hi Andrea:

    It's just like I guessed! :-D
    I've considered using PyData as a means of identification, but since
it's related to sorting I didn't make up my mind.
    Now my idea is that, I'd use a special property in the PyData object for
id, and provide __lt__, __gt__...etc.(which are irrelevant to id), when
sorting is needed.

Thanks,
    Harry Pan

2007/12/3, Andrea Gavana <andrea.gavana at gmail.com>:
>
> Hi Harry,
>
> On Dec 3, 2007 10:59 AM, Pan Xingzhi wrote:
> >     Is there a way to identify/track an item in a TreeCtrl? This action
> > typically takes place in an event handler where the exact "source" of
> the
> > event is needed.
> >     I tried event.GetItem(), but the returned TreeItemId instance is not
> the
> > one returned by AppendItem. However their m_pItem property looks the
> same.
> > Can I use that?
> >     I read the source code in the wxPython demo. It just retrieves the
> text
> > of the item using GetItemText(event.GetItem()). Though the TreeItemId
> > instance is changed, we can still get the same information (text,
> color...)
> > of the item. There must be some magic behind scene but I'm just
> confused.
>
> The TreeItemId generated by the C++ wxWidgets code is an
> evanescent/ghostly entity which may or may not change depending on
> what you do with the TreeCtrl. Using event.GetItem() will almost
> surely not returns the same TreeItemId as AppendItem. Depending on
> which are your needs, you might only use the item returned by
> event.GetItem(), or store some particular identifier into the item
> PyData (using SetPyData/GetPyData), or maybe use the m_pIten property
> (but I never used it and I don't even know what it's for). Or, as a
> last resort, you might switch to CustomTreeCtrl, which doesn't use any
> C++ :-D.
>
> Andrea.
>
> "Imagination Is The Only Weapon In The War Against Reality."
> http://xoomer.alice.it/infinity77/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help at lists.wxwidgets.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200712=
03/a44300d1/attachment.htm


More information about the wxpython-users mailing list