For the first time ever I seem to have found a major wart in wxWindows. For
some reason the GetNextXXX functions return "an invalid tree item" as a
terminator, instead of None (NULL).
There's GetChildrenCount to make it possible to walk the tree (though this
is mildly annoying since I'd rather be terminating on None). But I don't
see any way to get the number of visible items. So my question is: How do I
use GetNextVisible to iterate visible items? There seems to be no way to
know when to end the loop?
I guess a workaround would be to walk the whole tree and check each item for
visibility. If this is the best I can do, does this mean GetNextVisible is
utterly useless?
Is there a way to reliably test for an "invalid tree item" as returned by
these functions?
Is there a bug in the wxWindows (doesn't seem to be specific to wxPython)
database for this? Obviously this qualifies as a bug even though the
behaviour is consistent with documentation, since returning invalid item
handles is just plain stupid.
Documentation for wxTreeItemId is missing, but I found wxTreeItemId.IsOk in
the Boa Constructor code. Riaan Booysen seems to have access to a better
manual
···
For the first time ever I seem to have found a major wart in
wxWindows. For
some reason the GetNextXXX functions return "an invalid tree item" as a
terminator, instead of None (NULL).
There's GetChildrenCount to make it possible to walk the tree (though this
is mildly annoying since I'd rather be terminating on None). But I don't
see any way to get the number of visible items. So my question
is: How do I
use GetNextVisible to iterate visible items? There seems to be no way to
know when to end the loop?
I guess a workaround would be to walk the whole tree and check
each item for
visibility. If this is the best I can do, does this mean
GetNextVisible is
utterly useless?
Is there a way to reliably test for an "invalid tree item" as returned by
these functions?
Is there a bug in the wxWindows (doesn't seem to be specific to wxPython)
database for this? Obviously this qualifies as a bug even though the
behaviour is consistent with documentation, since returning invalid item
handles is just plain stupid.
For the first time ever I seem to have found a major wart in wxWindows.
For
some reason the GetNextXXX functions return "an invalid tree item" as a
terminator, instead of None (NULL).
The C++ method returns a reference, not a pointer, so it can't return NULL.
(If it did then it would automatically be converted to None.) Instead we
have the IsOk method.
There's GetChildrenCount to make it possible to walk the tree (though this
is mildly annoying since I'd rather be terminating on None). But I don't
see any way to get the number of visible items. So my question is: How do
I
use GetNextVisible to iterate visible items? There seems to be no way to
know when to end the loop?
if not item.IsOk(): break
should do it.
···
--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters? http://wxPython.org Relax with wxPython!