Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom headers organization in ListCtrl or another widget in wxPython

I've written code for ListCtrl in wxPython:

List Control

...
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 headers organization:

Headers organization

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

like image 291
dnlfinder Avatar asked Dec 29 '25 22:12

dnlfinder


1 Answers

As I pointed out on the wxPython mailing list where you cross-posted, the ListCtrl does not offer this capability. You might be able to do this with the Grid control (wx.grid.Grid) using column spanning techniques and your own sorting algorithms. You may be able to hack UltimateListCtrl to do this since it's pure Python instead of a wrapped C++ object, but that will be a non-trivial patch / hack.

Probably the best approach would be to roll your own widget. There are examples of custom widgets in the wxPython wiki, the wxPython demo and on their mailing list.

like image 84
Mike Driscoll Avatar answered Jan 01 '26 13:01

Mike Driscoll



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!