How to set UltimateListCtrl column header colors

Anyone know?

For example, to get a bold red header font, I tried:

boldfont = wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, False, u’Tahoma’)

for headertext in a_list_of_column_header_names:

        info = ULC.UltimateListItem()
        info._format = wx.LIST_FORMAT_LEFT
        info._mask = wx.LIST_MASK_TEXT | ULC.ULC_MASK_FONTCOLOUR | wx.LIST_MASK_IMAGE | wx.LIST_MASK_FORMAT | ULC.ULC_MASK_FONT

        info._image = []
        info._text = headertext
        info._font = boldfont
        info._colour = wx.RED
        i = col_list.index(headertext)

self.listCtrl1.InsertColumnInfo(i, info)

The headers are then bold, but they remain black, not red. The demo doesn’t seem to show an example of the header font color being changed. But the docs claim it is possible:

“* Column headers are fully customizable in terms of icons, colour, font, alignment etc…;”

No idea what to do. Thanks,
Che

Ok, I think you need to use a custom rendered for the header… messing with the UltimateReportDemo.py file in the wxpython demos (download separate from the wxpython website) I got a red background to show up (and was able to change the text/foreground with some messing around too, but here the text stays black always)

class UltimateHeaderRenderer(object):

def __init__(self, parent):

    self._hover = False

    self._pressed = False

    

def DrawHeaderButton(self, dc, rect, flags):

    

    self._hover = False

    self._pressed = False

    

    color = wx.Colour(255,0,0)

    

    if flags & wx.CONTROL_DISABLED:

        color = wx.Colour(wx.WHITE)

    elif flags & wx.CONTROL_SELECTED:

        color = wx.Colour(wx.BLUE)

            

    if flags & wx.CONTROL_PRESSED:

        self._pressed = True

        color = cutils.AdjustColour(color,-50)

    elif flags & wx.CONTROL_CURRENT:

        self._hover = True

        color = cutils.AdjustColour(color,-50)

    

    dc.SetBrush(wx.Brush(color, wx.SOLID))

    dc.SetBackgroundMode(wx.SOLID)

    dc.SetPen(wx.TRANSPARENT_PEN)

    dc.DrawRectangleRect(rect)

    dc.SetBackgroundMode(wx.TRANSPARENT)        

def GetForegroundColour(self):

    """

    if self._hover:

        return wx.Colour(255,255,255)

    else:

        return wx.Colour(0,0,0)

    """



    info = ULC.UltimateListItem()

    info._mask = wx.LIST_MASK_TEXT | wx.LIST_MASK_FORMAT

    info._format = 0

    info._text = "My Renderer"

    #info._colour = wx.Colour(255,0,0)  #this does nothing, :(

    

    # Add our custom renderer for the header of column 3, we can also use

    # SetHeaderCustomRenderer to set the renderer for all the columns.

    klass = UltimateHeaderRenderer(self)

    info.SetCustomRenderer(klass) 
···

On Sunday, March 16, 2014 12:37:06 PM UTC-7, Che M wrote:

Anyone know?

For example, to get a bold red header font, I tried:

boldfont = wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, False, u’Tahoma’)

for headertext in a_list_of_column_header_names:

        info = ULC.UltimateListItem()
        info._format = wx.LIST_FORMAT_LEFT
        info._mask = wx.LIST_MASK_TEXT | ULC.ULC_MASK_FONTCOLOUR | wx.LIST_MASK_IMAGE | wx.LIST_MASK_FORMAT | ULC.ULC_MASK_FONT


        info._image = []
        info._text = headertext
        info._font = boldfont
        info._colour = wx.RED
        i = col_list.index(headertext)

self.listCtrl1.InsertColumnInfo(i, info)

The headers are then bold, but they remain black, not red. The demo doesn’t seem to show an example of the header font color being changed. But the docs claim it is possible:

“* Column headers are fully customizable in terms of icons, colour, font, alignment etc…;”

No idea what to do. Thanks,
Che