2009-11-23 18 views

Respuesta

20

Aquí es

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() 
2

Según el color que necesite establecer, consulte el método SetForegroundColour() o SetBackgroundColour().

1

Esto debería funcionar:

text.SetForegroundColour(wx.Colour(255,255,255)) 

Si usted lo está utilizando en el interior del panel o la clase de marco a continuación:

self.text.SetForegroundColour(wx.Colour(255,255,255)) 

wx.Colour toma valores RGB cuales puede ser utilizado para diferentes colores.

0

Con wxPython Phoenix (no sé sobre wxPython clásica), se puede utilizar:

static_text = wx.StaticText(parent) 
static_text.SetLabelMarkup("<span foreground='red'>Some text</span>") 

Ver the Control class documentation para obtener más información acerca de la función SetLabelMarkup.

Cuestiones relacionadas