views:

1890

answers:

2

I want to have certain rows selected color be red instead of the standard color (blue on windows) so that I can indicate status. Anyone know if this is possible in wxPython?

+3  A: 

In your class that you derive from wx.ListCtrl, take a look at overriding

def OnGetItemAttr(self, item):
    return self.normalAttr[item % 2]
#

Where the item attributes are initialized ahead of time using:

    self.normalAttr = []
    self.normalAttr.append(wx.ListItemAttr())
    grayAttr = wx.ListItemAttr()
    grayAttr.SetBackgroundColour(lightGray)
    self.normalAttr.append(grayAttr)

So in this case, I'm alternating background colors between the default, and a light Gray attribute.

This function is called for each row as its painted, so you can use it to indicate all sorts of status. If row is selected should be an easy case.

Jim Carroll
+1  A: 
m-sharp