Custom columns organization in ListCtrl or another widget in wxPython

I’ve written code for ListCtrl in wxPython:

...
self.list_ctrl = wx.ListCtrl(panel, size=(-1,150), style=wx.LC_REPORT|wx.BORDER_SUNKEN)
self.list_ctrl.InsertColumn(0, 'Name')
self.list_ctrl.InsertColumn(1, 'Old value')
self.list_ctrl.InsertColumn(2, 'New value')
self.list_ctrl.InsertColumn(3, 'Old percent')
self.list_ctrl.InsertColumn(4, 'New percent')
...

But I want to get the ListCtrl (or another widget) with following Column organization:

I think that It hardy to solve this problem using ListCtrl, may be use another widget in wxPython?

Hi,

The ListCtrl can’t do that sort of thing. You might be able to bend the wx.grid.Grid widget to your will to do something like that though. Or there is a remote possibility that you could hack the UltimateListCtrl to do that, but personally I think you’d have to create your own custom widget.

  • Mike

There is something I wrote once and then kind of abandoned; maybe it will suit your needs. It’s part of Task Coach (GPLv3) and you can find it here:

https://svn.code.sf.net/p/taskcoach/code/branches/Feature_CategoryGrid/taskcoach/taskcoachlib/widgets

in ultimatetreectrl.py. Launch it directly for a demo.

Screenshot (OSX):

utreectrl.png

It's not too hard to draw your own column labels in the Grid class. In fact, there is a module in the library makes it fairly easy. Take a look at the wx.lib.mixins.gridlabelrenderer module.

···

On 10/29/12 9:23 AM, Mike Driscoll wrote:

Hi,

The ListCtrl can't do that sort of thing. You might be able to bend the
wx.grid.Grid widget to your will to do something like that though. Or
there is a remote possibility that you could hack the UltimateListCtrl
to do that, but personally I think you'd have to create your own custom
widget.

--
Robin Dunn
Software Craftsman