tags:

views:

22

answers:

2

Hi All

When i tried to run the following code. I am getting error.

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

i got this error

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

What i am doing wrong?

Second, can we add percentage number within gauge control.

Regards,

A: 

Few checkpoints

  • try removing wx.TR_FULL_ROW_HIGHLIGHT
  • try removing ,120 from self.tree.AddColumn("c1", 120) & self.tree.AddColumn("c3", 120)
S.Mark
A: 

this a known bug that's fixed in SVN -- http://trac.wxwidgets.org/ticket/11708

Download http://svn.wxwidgets.org/svn/wx/wxPython/3rdParty/AGW/agw/hypertreelist.py and use it in your application directly instead of using the one inside wx.

Steven Sproat