wxPython - How to add sorting to a ListCtrl?

R

Robert Dailey

Hi,

I have 3 columns in my list control, each with a different "type" of
data (for example, one column has names, the other has dates, etc).
Can anyone reference a tutorial for solving this issue? I've done my
share of googling to no avail. I need the user to be able to click any
of the column headers and sort the rows of data by that column in
ascending or descending order.

Thanks for your time.
 
K

kyosohma

Hi,

I have 3 columns in my list control, each with a different "type" of
data (for example, one column has names, the other has dates, etc).
Can anyone reference a tutorial for solving this issue? I've done my
share of googling to no avail. I need the user to be able to click any
of the column headers and sort the rows of data by that column in
ascending or descending order.

Thanks for your time.

Look at the wxPython demo. If you look at the list control's demo
code, you'll see they're using a mixin called "ColumnSorterMixin" that
will do what you need.

The demo can be found here: http://www.wxpython.org/download.php

Mike
 
J

Jason

Hi,

I have 3 columns in my list control, each with a different "type" of
data (for example, one column has names, the other has dates, etc).
Can anyone reference a tutorial for solving this issue? I've done my
share of googling to no avail. I need the user to be able to click any
of the column headers and sort the rows of data by that column in
ascending or descending order.

Thanks for your time.

You probably want to post these questions to the wxPython forums.
Still, take a look at the wxPython demo [1]. Under the "Core Windows/
Controls" category, the ListCtrl demo does exactly what you describe.
They have code and comments built into the demo itself.

[1] http://www.wxpython.org/download.php

--Jason
 
B

Benjamin

Hi,

I have 3 columns in my list control, each with a different "type" of
data (for example, one column has names, the other has dates, etc).
Can anyone reference a tutorial for solving this issue? I've done my
share of googling to no avail. I need the user to be able to click any
of the column headers and sort the rows of data by that column in
ascending or descending order.
There is a mixin for this at wx.lib.mixins.listctrl.ColumnSorterMixin.
To learn how to use it, take a look at the wxPython demo which comes
with the doc distribution. There's a good example in the ListCtrl
demo.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,076
Latest member
OrderKetoBeez

Latest Threads

Top