繁体   English   中英

wx.Hypertreelist-如何向其中添加小部件? /如何使文字可编辑?

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

最近我找到了Hypertreelist,这似乎是我所需要的,但是没有任何好的例子。 所以我有几个问题:

  • 如何添加wx.Widgets? 就像放置一个组合框
  • 如何使行内的文本可编辑? 竞争Doubleclick会很好

到目前为止,这是我的代码:

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()

您可以使用HitTest和EditLabel进行尝试。 代码看起来像这样:

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()       

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM