SetItemData error

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

SetItemData error

Donn Ingle
Hi again,
 Been trying the old "sort a ListCtrl" using collation thing and I can't get
off the ground. It's been at least 1 year since I last asked about this
here and I have not had time since then to get back on to it.

I am keeping a internal dict (d) to link text to id numbers. I want to use
the id in the SetItemData so that SortItem will access it. I can't get past
this however:

for i in somelistofstrings:
        id = wx.NewId()
        self.d[id] = i
        li = wx.ListItem()
        li.SetText ( i )
        self.InsertItem( li )
        self.SetItemData( li, long(id) )

 
File "/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/_controls.py",
line 4553, in SetItemData
    return _controls_.ListCtrl_SetItemData(*args, **kwargs)
TypeError: in method 'ListCtrl_SetItemData', expected argument 2 of
type 'long'

eh?
\d


Reply | Threaded
Open this post in threaded view
|

Re: SetItemData error

jonhattan-2
Donn Ingle escribió:

> Hi again,
>  Been trying the old "sort a ListCtrl" using collation thing and I can't get
> off the ground. It's been at least 1 year since I last asked about this
> here and I have not had time since then to get back on to it.
>
> I am keeping a internal dict (d) to link text to id numbers. I want to use
> the id in the SetItemData so that SortItem will access it. I can't get past
> this however:
>
> for i in somelistofstrings:
>         id = wx.NewId()
>         self.d[id] = i
>         li = wx.ListItem()
>         li.SetText ( i )
>         self.InsertItem( li )
>         self.SetItemData( li, long(id) )
>
>  
the first arg to SetItemData is the return value of InsertItem:

row = self.InsertItem( li )
self.SetItemData( row, long(id) )



--jonhattan


>  
> File "/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/_controls.py",
> line 4553, in SetItemData
>     return _controls_.ListCtrl_SetItemData(*args, **kwargs)
> TypeError: in method 'ListCtrl_SetItemData', expected argument 2 of
> type 'long'
>
> eh?
> \d
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
>  


Reply | Threaded
Open this post in threaded view
|

Re: SetItemData error

Donn Ingle
> the first arg to SetItemData is the return value of InsertItem:
>
> row = self.InsertItem( li )
> self.SetItemData( row, long(id) )
d slinks away in shame .... :D

\d