I need to make a StaticText red, what should I use?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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()
回答2:
Depending on which color you would need to set, look into SetForegroundColour()
or SetBackgroundColour()
method.
回答3:
This should work:
text.SetForegroundColour(wx.Colour(255,255,255))
If you are using it inside the panel or frame's class then:
self.text.SetForegroundColour(wx.Colour(255,255,255))
wx.Colour
takes RGB values which can be used for different colours.