首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >HyperTreeList指数超出范围问题?

HyperTreeList指数超出范围问题?
EN

Stack Overflow用户
提问于 2010-03-05 05:12:57
回答 2查看 347关注 0票数 0

当我试图运行以下代码时。我搞错了。

代码语言:javascript
运行
复制
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()

我犯了这个错误

代码语言:javascript
运行
复制
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

我做错什么了?

第二,我们可以在量规控制中增加百分比数吗?

致以敬意,

EN

回答 2

Stack Overflow用户

发布于 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内部的应用程序。

票数 1
EN

Stack Overflow用户

发布于 2010-03-05 05:40:46

很少有检查站

wx.TR_FULL_ROW_HIGHLIGHT

  • try

  • 尝试删除self.tree.AddColumn("c1", 120) & self.tree.AddColumn("c3", 120)

中的,120

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2384700

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档