[wxPython-users] Re: Sorted List Control - how?
Robin Dunn
robin at alldunn.com
Mon Dec 11 22:35:54 PST 2006
Peter Hansen wrote:
> Donn Ingle wrote:
>>> The docs show a SortItems() call that does this. (Note it doesn't
>>> "maintain" it for you... you just call that method to ensure it is
>>> sorted whenever you want it to be.)
>> Thanks, I dunno how I missed that one. I'll go have another look.
>
> The interface for wxPython might be non-obvious, especially to a
> beginner (not sure if you are one or not). Here's a trivialized example
> you can probably build on, which should explain what the note about "a
> callable object" means in the C++ docs:
>
> 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.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wxpython-users
mailing list