[Q]: wxTreeCtrl and IsOK

For a wxTreeCtrl T that contains an Item I, I do:

      T.Delete(I)

Immediately following:

      assert not I.IsOk()

The assertion fails. The deleted item is ok?

It's out of the tree. The Delete(I) takes it out.

Assuming that I can live with this, I try:

def TreeContains(T, I):
  T.Delete(I)
  try:
    T.SelectItem(I)
    return True
  except:
    return False

And it returns True. Assuming I can drive without a
rearview mirror, what do I do to detect the sound of
broken glass?

Al

achrist@easystreet.com wrote:

Assuming that I can live with this, I try:

def TreeContains(T, I):
  T.Delete(I)
  try:
    T.SelectItem(I)
    return True
  except:
    return False

And it returns True.

Is an item selected?

The wxTreeItemId class is just a platform independent wrapper around a platform dependent tree item handle and there is nothing that will invalidiate the handles if an item is deleted.

Depending on the platform the handle may just be an index into a data structure and so calling SelectItem may select the next item after the one that was deleted...

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!