Search code examples
pythonwxpython

python: set the color of a single line in a list view


I'm doing some tests and create a list that displays the results of those tests in a gui

self.listCtrl1 = wx.ListCtrl(id=wxID_FRAME1LISTCTRL1, name='listCtrl1',
          parent=self.panel1, pos=wx.Point(15, 24), size=wx.Size(808, 419),
          style=wx.LC_REPORT)
self._init_coll_listCtrl1_Columns(self.listCtrl1)

self.listCtrl1.Append([datetime.datetime.now(),action,result])

What I would like to do is to change the color of each item in the list based upon if the test passed or failed. How is this done (if it can be)


Solution

  • It can be done with SetItemBackgroundColor. Check the API for details: http://www.wxpython.org/docs/api/wx.ListCtrl-class.html