Colorized output for logging memoryhandler and wx.ListCtrl using Append()

Frank Aune Frank.Aune at broadpark.no
Wed Oct 24 00:57:29 PDT 2007


Hi,

Ive got a logging memory handler, which outputs the log to a textctrl using 
Append():

---
def flush(self):
        """
        Thread safe flush method which schedule the
        widget update after a wx main loop ends
        """
        for record in self.buffer:
            msg = self.format(record)
            try:
                msg = msg.split(' ')
                msg = (msg[0] + ' ' + msg[1], msg[2], msg[3], 
self.formatLine(msg[4:]))
                wx.CallAfter(self.widget.Append, msg)
            except AttributeError, e:
                pass
        self.buffer = []
---

I want to know if there is any way to colorize the text in the listCtrl, 
without using:

- VirtualListCtrl using OnGetItemAttr() (which works, although not suited 
here - I need the ListCtrl to be defined in an XRC in order to keep its 
content even when "stuff" happens in the back)

- Running Append(), GetItem(), SetItemTextColour(), and SetItem() again (!!!)

Basically I'd want Append() to work with items already formatted for a special 
colour, but it doesn't seem Append() accepts wx.ListItem()

Thanks,
-Frank




More information about the wxpython-users mailing list