Search code examples
pythonwxpythonwxwidgets

Getting selection of wx.treectrl


tree.GetSelection() gives the actual tree id object.

I would like to get a int of the selection just like a listbox.GetSelection() would return.

Does anyone know how to do this?


Solution

  • The TreeItemId object should have a GetID method which will return its id in the tree

    Edit

    the tree control has a built in feature to store additional information on the tree item.

    item= self.tree.GetSelection()
    self.tree.SetPyData(item,{"Source":"C:\hi.png","Opacity":1})
    print self.tree.GetPyData(item)