Hello,
I am running python 2.4.4 with wxpython 2.6 on Fedora 6. I am trying to set the font color of individual elements in a listbox, but I am not able to with SetItemForegrou ndColour() (this method does not appear to do anything):
However, I am able to set the font color of all the elements with SetForegroundCo lour(). I want to be able to have each color represent the current state of an element. I know that I can do this with a listctrl, but I wanted to try to do it with a listbox. Any help is greatly appreciated.
Thanks in advance,
Stephen
I am running python 2.4.4 with wxpython 2.6 on Fedora 6. I am trying to set the font color of individual elements in a listbox, but I am not able to with SetItemForegrou ndColour() (this method does not appear to do anything):
Code:
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# generated by wxGlade 0.4.1 on Thu Mar 22 12:15:29 2007
import wx
class MyFrame(wx.Frame):
def __init__(self, *args, **kwds):
# begin wxGlade: MyFrame.__init__
kwds["style"] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
self.list_box_1 = wx.ListBox(self, -1, choices=["One", "Two"])
self.__set_properties()
self.__do_layout()
self.Bind(wx.EVT_LISTBOX, self.OnSelect, self.list_box_1)
# end wxGlade
def __set_properties(self):
# begin wxGlade: MyFrame.__set_properties
self.SetTitle("frame_1")
self.list_box_1.SetSelection(0)
# end wxGlade
def __do_layout(self):
# begin wxGlade: MyFrame.__do_layout
sizer_1 = wx.BoxSizer(wx.VERTICAL)
sizer_1.Add(self.list_box_1, 0, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
self.SetAutoLayout(True)
self.SetSizer(sizer_1)
sizer_1.Fit(self)
sizer_1.SetSizeHints(self)
self.Layout()
# end wxGlade
def OnSelect(self, event): # wxGlade: MyFrame.<event_handler>
self.list_box_1.SetItemForegroundColour(0,wx.RED)
self.list_box_1.SetItemForegroundColour(1,wx.BLUE)
# end of class MyFrame
if __name__ == "__main__":
app = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
frame_1 = MyFrame(None, -1, "")
app.SetTopWindow(frame_1)
frame_1.Show()
app.MainLoop()
Thanks in advance,
Stephen
Comment