Hi,
I am using:
python: 2.3.4
wxPython: 2.5.2.8
I am trying to use the InsertItem() method of wx.ListCtrl. Whenver I call
InsertItem() to insert the first item it raises the exception given below. I
have tried this a couple of different ways. The simplest is given below the
exception. What am I missing?
Thanks,
Tom
Traceback (most recent call last):
File "./listctrl.py", line 52, in ?
app = MyApp(0)
File "/usr/local/lib/python2.3/site-packages/wx/_core.py", line 5243, in
__init__
self._BootstrapApp()
File "/usr/local/lib/python2.3/site-packages/wx/_core.py", line 4931, in
_BootstrapApp
return _core_.PyApp__BootstrapApp(*args, **kwargs)
File "./listctrl.py", line 44, in OnInit
frame = MyFrame(None, -1, "")
File "./listctrl.py", line 21, in __init__
self.list.InsertItem(info)
File "/usr/local/lib/python2.3/site-packages/wx/_controls.py", line 4476, in
InsertItem
return _controls_.ListCtrl_InsertItem(*args, **kwargs)
wx._core.PyAssertionError: C++ assertion "wxAssertFailure" failed in
../src/common/list.cpp(326): invalid index in wxListBase::Item
<code>
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# generated by wxGlade 0.3.4 on Sun Sep 19 12:04:31 2004
import wx
class MyFrame(wx.Frame):
def __init__(self, *args, **kwds):
# begin wxGlade: MyFrame.__init__
kwds["style"] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
self.list = wx.ListCtrl(self, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)
self.__set_properties()
self.__do_layout()
# end wxGlade
info = wx.ListItem()
info.SetText('Test 1')
self.list.InsertItem(info)
def __set_properties(self):
# begin wxGlade: MyFrame.__set_properties
self.SetTitle("Test List Control")
# end wxGlade
def __do_layout(self):
# begin wxGlade: MyFrame.__do_layout
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.list, 1, wx.EXPAND, 0)
self.SetAutoLayout(1)
self.SetSizer(sizer)
sizer.Fit(self)
sizer.SetSizeHints(self)
self.Layout()
# end wxGlade
# end of class MyFrame
class MyApp(wx.App):
def OnInit(self):
wx.InitAllImageHandlers()
frame = MyFrame(None, -1, "")
self.SetTopWindow(frame)
frame.Show(1)
return 1
# end of class MyApp
if __name__ == "__main__":
app = MyApp(0)
app.MainLoop()
</code>