[wxPython-users] TreeCtrl GetNextVisible

Saketh Bhamidipati saketh.bhamidipati at gmail.com
Fri Sep 1 09:52:48 PDT 2006


On 9/1/06, Saketh Bhamidipati <saketh.bhamidipati at gmail.com> wrote:
>
>
>
> On 9/1/06, Robin Dunn <robin at alldunn.com> wrote:
> >
> > Saketh Bhamidipati wrote:
> > > A method of mine iterates through a TreeCtrl and writes data to an XML
> > > file using ElementTree. In order to move the iterator forward, I use
> > > GetNextVisible. When writing this method, I did not know that the node
> >
> > > actually has to be visible for GetNextVisible to return it. This is
> > > causing problems for me now that I have many nodes in a TreeCtrl that
> > > require a scrollbar.
> > >
> > > I still want to iterate through the TreeCtrl, but without the major
> > > issue that all nodes must be visible for the iteration to work.
> > >
> >
> > Use GetFirstChild/GetNextChild.
> >
> > --
> > Robin Dunn
> > Software Craftsman
> > http://wxPython.org   Java give you jitters?  Relax with wxPython!
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: wxPython-users-unsubscribe at lists.wxwidgets.org
> > For additional commands, e-mail: wxPython-users-help at lists.wxwidgets.org
> >
> > I got it to work with this code:
>         while current.IsOk ():
>             new =3D None
>
>             if current =3D=3D self.tree.GetRootItem():
>                 new =3D self.tree.GetFirstChild(current)
>
>             else:
>                 new =3D self.tree.GetNextSibling (current)
>
>
>             current =3D new
>             if not current.IsOk(): break
>
>             # Start translating the data
>             new =3D SubElement(root, "node")
>             new.set("title", unicode( self.tree.GetItemText
> (current)).encode('utf8'))
>
>             data =3D SubElement(new, "data")
>             datatext =3D unicode(self.tree.GetPyData
> (current)).encode('utf8')
>             if datatext =3D=3D 'None':
>                         datatext =3D "" # Again, we don't want it to
> literally write 'None'
>             data.text =3D datatext
>
>         tree =3D ElementTree(root)
>         tree.write(unicode(filename))
>
> But I have a problem - if the user minimizes the root node, nothing but
> the root node gets written. How can I fix this?
>
Actually, I could solve this problem if I just made the root node
unminimizable. How can I do that?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200609=
01/c1304726/attachment.htm


More information about the wxpython-users mailing list