Sorting a ListCtrl

Hi,

Is there an example python script demonstrating how to sort rows in a list control? Suppose I have a list control with 4 columns and I want each to be sortable descending / ascending. From the documentation I’ve read this seems to be a fairly complex procedure. Example code would probably get me on my way.

Thanks.

Look in the mixins for ListCtrl. They have one that will sort by
column on a column click. I had to refactor a small bit of code to add
the required sorting procedure, but it's well worth the effort and
makes the application much more usable.

I think its the mixins.ListCtrl.ColumnSorter mixin.

Josh

···

On 10/1/07, Robert Dailey <rcdailey@gmail.com> wrote:

Hi,

Is there an example python script demonstrating how to sort rows in a list
control? Suppose I have a list control with 4 columns and I want each to be
sortable descending / ascending. From the documentation I've read this seems
to be a fairly complex procedure. Example code would probably get me on my
way.

Thanks.

--
Josh English
Joshua.R.English@gmail.com

Robert,

···

-----Original Message-----
From: Robert Dailey [mailto:rcdailey@gmail.com]
Sent: Monday, October 01, 2007 3:35 PM
To: wxPython
Subject: Sorting a ListCtrl

Hi,

Is there an example python script demonstrating how to sort
rows in a list control? Suppose I have a list control with 4
columns and I want each to be sortable descending /
ascending. From the documentation I've read this seems to be
a fairly complex procedure. Example code would probably get
me on my way.

Thanks.

The wxPython Demo shows how to do exactly what you're looking for. They
basically subclass the ColumnSorterMixin and it does the work for you.
Just download the demo and check out the ListCtrl demo source.

Mike

Josh English wrote:

Look in the mixins for ListCtrl. They have one that will sort by
column on a column click. I had to refactor a small bit of code to add
the required sorting procedure, but it's well worth the effort and
makes the application much more usable.

I think its the mixins.ListCtrl.ColumnSorter mixin.

wx.lib.mixins.listctrl.ColumnSorterMixin

It's also shown in the main ListCtrl sample in the demo.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Thanks everyone for your responses.