Search code examples
pythonpython-3.xuser-interfacewxpython

wx.Hypertreelist - How add widgets to it? / How make texts editable?


Recently i found Hypertreelist, it seems to be what i Need, but there arent any good examples. So i have a few questions:

  • How do I add wx.Widgets to it? Like placing a Combobox
  • How do i make the Texts inside a row editable? Vie Doubleclick would be good

Here is my Code so far:

import wx
import wx.lib.agw.hypertreelist as HTL

class MyFrame(wx.Frame):
    def __init__(self, parent):
        wx.Frame.__init__(self, parent, -1, "HyperTreeList Demo")

        tree_list = HTL.HyperTreeList(self)
        tree_list.AddColumn("First column")
        root = tree_list.AddRoot("Root")
        parent = tree_list.AppendItem(root, "First child")
        child = tree_list.AppendItem(parent, "First Grandchild")
        tree_list.AppendItem(root, "Second child")

app = wx.App(0)
frame = MyFrame(None)
app.SetTopWindow(frame)
frame.Show()
app.MainLoop()

Solution

  • You could try it with a HitTest and EditLabel. The code could look like this:

    pt = event.GetPosition()
        item, flags, column = self.tree.HitTest(pt)
    
        if "CP" in item.GetText():
            if column > 1:
                self.tree.EditLabel(item, column)    
        event.Skip()