djneu@att.net wrote:
Hi-
I'm using wxPython 2.4.0.1 on Windows 2000.
I've included a small example which includes
a wxListCtrl, and shows how to control the sorting of columns.To get it to work I had to make the following
call:
self.list.SetItemData(0, i)My questions are:
a) Why is this call necessary?
The values passed to the compare function are not row indexes but are the data values associated with the item, so if the items have no data value you have no way to get to the column values to be sorted.
b) What exactly does it do?
Associates a data value with the list item. Even if the item changes position in the control the data value associated with it will stay the same.
c) Is this the "correct" way to handle sorting?
Yes. Another way is to use the wxLC_VIRTUAL style and instead of preloading values into the control it will ask you for them when it needs to display them. Then sorting becomes just a matter of sorting your data and then refreshing the control.
···
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!