当我试图运行以下代码时。我搞错了。
import wx
from wx.lib.agw.hypertreelist import HyperTreeList
class test(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, -1, title='htl', size=(955,550))
        self.CenterOnScreen()
        self.tree = HyperTreeList(self, style =
                                            wx.TR_FULL_ROW_HIGHLIGHT |
wx.TR_HAS_VARIABLE_ROW_HEIGHT)
        # create columns
        self.tree.AddColumn("c1", 120)
        self.tree.AddColumn("c1")
        self.tree.AddColumn("c3", 120)
        self.tree.AddColumn("c4")
        self.tree.AddColumn("c5")
        self.tree.AddColumn("c6")
        self.tree.AddColumn("c7")
        self.tree.AddColumn("c8")
        self.tree.AddColumn("c9")
        root = self.tree.AddRoot("root")
        rc = self.tree.AppendItem(root, "child1")
        rc2 = self.tree.AppendItem(root, "child2")
        gauge = wx.Gauge(self.tree.GetMainWindow(), -1, 100,
style=wx.GA_HORIZONTAL|wx.GA_SMOOTH)
        gauge.SetValue(25)   *#can we add this value over/within gauge
control/window*
        gauge.SetDimensions(100, 100, 100, 20)
        self.tree.SetItemWindow(rc2, gauge, 7)  #here is problem
        self.tree.Expand(root)
    #end def
#end test
class App(wx.App):
    """Application class."""
    def OnInit(self):
        self.frame = test()
        self.frame.Show()
        self.SetTopWindow(self.frame)
        return True
def main():
    app = App()
    app.MainLoop()
if __name__ == '__main__':
    main()我犯了这个错误
Traceback (most recent call last):
  File "/root/workspace/test/src/test.py", line 61, in <module>
    main()
  File "/root/workspace/test/src/test.py", line 57, in main
    app = App()
  File "/usr/lib/python2.6/site-packages/wx-2.8-gtk2-unicode/wx/_core.py",
line 7974, in __init__
    self._BootstrapApp()
  File "/usr/lib/python2.6/site-packages/wx-2.8-gtk2-unicode/wx/_core.py",
line 7548, in _BootstrapApp
    return _core_.PyApp__BootstrapApp(*args, **kwargs)
  File "/root/workspace/test/src/test.py", line 51, in OnInit
    self.frame = test()
  File "/root/workspace/test/src/test.py", line 39, in __init__
    self.tree.SetItemWindow(rc2, gauge, 7)
  File
"/usr/lib/python2.6/site-packages/wx-2.8-gtk2-unicode/wx/lib/agw/hypertreelist.py",
line 3282, in delegate
    return getattr(self._main_win, method)(*args, **kwargs)
  File
"/usr/lib/python2.6/site-packages/wx-2.8-gtk2-unicode/wx/lib/agw/hypertreelist.py",
line 1414, in SetItemWindow
    item.SetWindow(window, column)
  File
"/usr/lib/python2.6/site-packages/wx-2.8-gtk2-unicode/wx/lib/agw/hypertreelist.py",
line 1055, in SetWindow
    self._wnd[column] = wnd
IndexError: list assignment index out of range我做错什么了?
第二,我们可以在量规控制中增加百分比数吗?
致以敬意,
发布于 2010-03-05 10:17:18
这是一个已知的错误,在SVN中是固定的-- http://trac.wxwidgets.org/ticket/11708
下载http://svn.wxwidgets.org/svn/wx/wxPython/3rdParty/AGW/agw/hypertreelist.py并直接在应用程序中使用它,而不是使用wx内部的应用程序。
发布于 2010-03-05 05:40:46
很少有检查站
wx.TR_FULL_ROW_HIGHLIGHT
self.tree.AddColumn("c1", 120) & self.tree.AddColumn("c3", 120)
中的,120
https://stackoverflow.com/questions/2384700
复制相似问题