Re: [wxpython-users] wx.ListCtrl Error When Loading Values
by Phil Mayes other posts by this author
May 8 2008 5:29PM messages near this date
Re: [wxpython-users] wx.ListCtrl Error When Loading Values -- SOLVED
|
Re: [wxpython-users] wx.ListCtrl Error When Loading Values
At 04:59 PM 5/8/2008, you wrote:
> I don't see what's causing the error here:
>
> File "/data1/eikos/rulePage.py", line 83, in displayValues
> self.rulesList.InsertStringItem(item, 0, self.appData.rules[0])
> File
> "/usr/lib/python2.4/site-packages/wx-2.8-gtk2-unicode/wx/_controls.py", line
> 4698, in InsertStringItem
> return _controls_.ListCtrl_InsertStringItem(*args, **kwargs)
> TypeError: in method 'ListCtrl_InsertStringItem', expected argument 2 of
> type 'long'
>
> Here's the code (with the referenced line 83 marked with a hash):
>
> def displayValues(self, event):
> for item in self.appData.rules:
> self.rulesList.InsertStringItem(item, 0, self.appData.rules[0])
> #self.rulesList.InsertStringItem(item, 1, self.appData.rules[1])
> self.rulesList.InsertStringItem(item, 2, self.appData.rules[2])
> self.rulesList.InsertStringItem(item, 3, self.appData.rules[3])
> self.rulesList.InsertStringItem(item, 4, self.appData.rules[4])
>
> There's only one row in self.appData.rules:
>
> [(u'Variety', u'Fish', u'Wildlife', u'WFV2', u'if variety is high then
> goodness is very increased')]
>
> What I read in the wPIA book is that InsertStringItem() -- without images
> -- takes the row (here with the 'item' index), the column, and the string to
> be inserted. So, I am not seeing what I've done incorrectly.
>
> A clue stick is appreciated.
>
> Rich
Hi Rich,
This is due to Windows' brain-dead interface design. You have to use
InsertStringItem for the entry in column 0, and SetStringItem for the rest
of the columns. Do something like:
idx = self.list.InsertStringItem(sys.maxint, col0)
self.list.SetStringItem(idx, 1, col1)
self.list.SetStringItem(idx, 2, col2)
self.list.SetStringItem(idx, 3, item.title)
Phil
_______________________________________________
wxpython-users mailing list
wxpython-users@[...].org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Thread:
Rich Shepard
Tim Roberts
Rich Shepard
Phil Mayes
Rich Shepard
|