Change the colour of a StaticText, wxPython

Gabriele Cirulli picture Gabriele Cirulli · Nov 23, 2009 · Viewed 25.4k times · Source

I need to make a StaticText red, what should I use?

Answer

Anurag Uniyal picture Anurag Uniyal · Dec 3, 2009

Here it is

import wx

app=wx.PySimpleApp()
frame=wx.Frame(None)
text=wx.StaticText(frame, label="Colored text")
text.SetForegroundColour((255,0,0)) # set text color
text.SetBackgroundColour((0,0,255)) # set text back color
frame.Show(True)
app.MainLoop()