开发者

Change the colour of a StaticText, wxPython

开发者 https://www.devze.com 2022-12-12 12:55 出处:网络
I need to make a StaticText 开发者_如何学JAVAred, what should I use?Here it is import wx app=wx.PySimpleApp()

I need to make a StaticText 开发者_如何学JAVAred, what should I use?


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


Depending on which color you would need to set, look into SetForegroundColour() or SetBackgroundColour() method.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号