[wxPython-users] Re: Sorted List Control - how?

Peter Hansen peter at engcorp.com
Tue Dec 12 09:56:17 PST 2006


Robin Dunn wrote:
> Peter Hansen wrote:
>> Define a sorter class, something like this.  It exists basically so 
>> __call__() can be defined for it:
>>
>> class _StepSorter(object):
>>     '''used in call to ListCtrl.SortItems()'''
>>     def __call__(self, a, b):
>>         # a and b were set by ListCtrl.SetItemData()
>>         return cmp(a, b)
> 
> A "callable object" doesn't have to be a class with a __call__ method. 
> It is anything that can be called, IOW, any foo for which foo(a,b) is 
> possible.

Oh, how very simple.  I think I misinterpreted the "wxPython" comments 
in the wxWidgets docs, about how the "SortData" parameter is not 
available for use.  Thanks for the correction.

-Peter




More information about the wxpython-users mailing list