Search code examples
pythonwxpythonwxwidgets

Renaming Item in a TreeCtrl


I am trying to make a rename feature for a Treectrl.

Where, a TextCtrl goes over the element and I am able to rename it. I cant find this feature on the API but I am sure that there has to be some way to do it.


Solution

  • I assume you want to rename tree elements (leaves), right? Well when you instantiate the TreeCtrl, give it the following style flags: wx.TR_DEFAULT_STYLE | wx.TR_EDIT_LABELS

    Now you should be able to click or double-click any of the items and rename them. See the wxPython demo for more cool tricks.