[wxPython-users] changing font colour

Robin Dunn robin at alldunn.com
Thu Sep 13 12:02:28 PDT 2007


Andrea Gavana wrote:
> Hi Robert,
> 
> On 9/10/07, Robert Gravina wrote:
>> I'd like a wx.StaticBox to draw it's text in white, rather than
>> black. I would assume that I just need to call SetForegroundColour on
>> the wx.StaticBox instance, so does anyone know why in this test
>> script (pasted and attached) the colour doesn't change?
> 
> Uhm, you're referring to wx.StaticBox but you're not actually using
> any wx.StaticBox in your code... You have a main wx.BoxSizer sizer in
> which you put a wx.StaticText.
> Anyway, wx.Colour accepts an rgb tuple/trio input, so you should
> correct the line:
> 
> label.SetForegroundColour(wx.Colour(wx.WHITE))
> 
> with:
> 
> label.SetForegroundColour(wx.WHITE)
> or:
> label.SetForegroundColour(wx.Colour(255, 255, 255))
>

Although depending on the platform the native static text widget may or 
may not be able to change color.  See wx.lib.stattext for a generic 
alternative.

-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!





More information about the wxpython-users mailing list