#改了代码 还是报错
##import wx
import sys
packages = [('jessica alba', 'pomona', '1981'),
('sigourney weaver', 'new york', '1949'),
('angelina jolie', 'los angeles', '1975'),
('natalie portman', 'jerusalem', '1981'),
('rachel weiss', 'london', '1971'),
('scarlett johansson', 'new york', '1984' )]
class Actresses(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, size=(380, 230))
hbox = wx.BoxSizer(wx.HORIZONTAL)
panel = wx.Panel(self, -1)
self.list = wx.ListCtrl(panel, -1, style=wx.LC_REPORT)
self.list.InsertColumn(0, 'name', width=140)
self.list.InsertColumn(1, 'place', width=130)
self.list.InsertColumn(2, 'year', wx.LIST_FORMAT_RIGHT, 90)
for i in packages:
index = self.list.InsertStringItem(sys.maxsize, i[0]) # python 2.0改 3.0 #sys.maxint需要改为maxsize //HZM
self.list.SetStringItem(index, 1, i[1])
self.list.SetStringItem(index, 2, i[2])
hbox.Add(self.list, 1, wx.EXPAND)
panel.SetSizer(hbox)
self.Centre()
self.Show(True)
app = wx.App()
Actresses(None, -1, 'actresses')
app.MainLoop()
#报错
wxPyDeprecationWarning: Call to deprecated item. Use InsertItem instead.
index = self.list.InsertStringItem(sys.maxsize, i[0])
return item(*args)
wx._core.wxAssertionError: C++ assertion "info.m_itemId != -1" failed at ....\src\msw\listctrl.cpp(1961) in wxListCtrl::InsertItem(): Item ID must be set.
#