wx.ListCtrl Error When Loading Values

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

···

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

This is due to Windows' brain-dead interface design.

Phil,

   If you refer to Microsoft's stuff, we don't touch it. Haven't for more
than a decade now. Strictly linux here. However, if it's a wxPython issue
then that's a different matter.

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)

   Ah, so! I do this in the function that adds new rules, but didn't do it
for the function that loads existing rules when the project database is
opened ... just made the adjustment.

   Now I'm getting a different error:

File "/data1/eikos/rulePage.py", line 82, in displayValues
     n = self.rulesList.InsertStringItem(sys.maxint, 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: String or Unicode type required

   And all the items in the tuple _are_ strings. So, closer but still not
there.

Thanks very much,

Rich

···

On Thu, 8 May 2008, Phil Mayes wrote:

--
Richard B. Shepard, Ph.D. | Integrity Credibility
Applied Ecosystem Services, Inc. | Innovation
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863