SetItemBackgroundColour

Hi all,

SetItemBackgroundColour for wx.ListBox doesn’t do anything.

Simple sample:

import os
import sys
import wx

class FileDisplay(wx.Frame):
def init(self, parent, id, title):
wx.Frame.init(self, parent, id, title, size=(390, 350))
self.panel = wx.Panel(self, -1)

    self.vbox = wx.BoxSizer(wx.VERTICAL)
   
    hbox1 = wx.BoxSizer(wx.HORIZONTAL)
    label = wx.StaticText(self.panel, -1, "file")
    hbox1.Add(label,0,wx.RIGHT, 8)
    text = wx.TextCtrl(self.panel, -1,"path")
    hbox1.Add(text, 1)
    self.vbox.Add(hbox1, 0, wx.EXPAND | wx.LEFT | wx.RIGHT, 10)
    self.vbox.Add((-1, 10))
    self.ListCtrl=wx.ListBox(self.panel, -1)
    self.ListCtrl.Bind(wx.EVT_LISTBOX, self.OnRightBtnClicked)       
    # populate
    for fn in os.listdir("."):
        self.ListCtrl.Append(fn)               
   
    hbox2=wx.BoxSizer(wx.HORIZONTAL)
    hbox2.Add(self.ListCtrl, 1, wx.EXPAND)
    self.vbox.Add(hbox2, 1, wx.LEFT)
   
    self.panel.SetSizer(self.vbox)
    self.Centre()
    self.Show(True)

def OnRightBtnClicked(self, event):
    self.ListCtrl.SetItemBackgroundColour(1,wx.RED)
    print "OnRightBtnClicked"
    event.Skip()

app = wx.App(redirect=False)
FileDisplay(None, -1, ‘FileDisplay’)
app.MainLoop()

Whats wrong with that code. OnRightBtnClicked is called. But the colour doesn’t change. Neither with SetItemBackgroundColour nor with SetItemForegroundColour.

Regards

Rudi