I am porting another project from Python27 to 37 & have found a difference between the handling of the ListCtrl ItemBackground colouring. (Windows 10)
With the same code, the ListCtrl is displayed slightly differently with thick white column lines on wx 4.1.1.
Whilst this is only a cosmetic change, I would like to understand how to control this behaviour.
I have read in some comments from Robin that wx4 uses the “system theme style” on windows & to disable this function I could use self.MylistCtrl.EnableSystemTheme(False)
but this doesnt seem to make any difference.
In the documentation there are the style wx.LC_HRULES ¦ wx.LC_VRULES
to add line separation.
Could it be that wx.LC_HRULES
is enabled by default with wx.LC_REPORT?
Is there a simple way to remove the column lines?
Short code example:
import wx
class MyFrame(wx.Frame):
def __init__(self, parent, title):
super(MyFrame, self).__init__(parent, title=title, size=(275, 150))
# Create a panel and a list control
panel = wx.Panel(self)
self.myListCtrl = wx.ListCtrl(panel, style=wx.LC_REPORT)
self.myListCtrl.EnableSystemTheme(False) # Remove this line for Python 2.7
# Add three columns to the list control
self.myListCtrl.InsertColumn(0, "Name")
self.myListCtrl.InsertColumn(1, "Age")
self.myListCtrl.InsertColumn(2, "Gender")
# Add some items to the list control
self.myListCtrl.Append(["Alice", "25", "Female"])
self.myListCtrl.Append(["Bob", "30", "Male"])
self.myListCtrl.Append(["Charlie", "35", "Male"])
self.myListCtrl.Append(["Dave", "30", "Female"])
for row in range(self.myListCtrl.GetItemCount()):
if row % 2 == 0:
self.myListCtrl.SetItemBackgroundColour(row, "green")
else:
self.myListCtrl.SetItemBackgroundColour(row, "red")
# Create a box sizer to layout the panel and the list control
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.myListCtrl, 1, wx.EXPAND)
panel.SetSizer(sizer)
self.Show()
app = wx.App()
MyFrame(None, "List Control Example")
app.MainLoop()
Thanks in advance for any ideas,
Gabbo