TreeCtrl GetNextVisible

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!

I got it to work with this code:
while current.IsOk
():
new = None

        if current == self.tree.GetRootItem():
            new = self.tree.GetFirstChild(current)

        else:
            new = self.tree.GetNextSibling

(current)

        current = new
        if not current.IsOk(): break

        # Start translating the data
        new = SubElement(root, "node")
        new.set("title", unicode(

self.tree.GetItemText(current)).encode(‘utf8’))

        data = SubElement(new, "data")
        datatext = unicode(self.tree.GetPyData(current)).encode('utf8')
        if datatext == 'None':

                    datatext = "" # Again, we don't want it to literally write 'None'
        data.text = datatext

    tree = 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?

···

On 9/1/06, Robin Dunn robin@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@lists.wxwidgets.org

For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org