Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change the colour of a StaticText, wxPython

Tags:

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

like image 536
Gabriele Cirulli Avatar asked Nov 23 '09 18:11

Gabriele Cirulli


3 Answers

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() 
like image 186
Anurag Uniyal Avatar answered Oct 31 '22 02:10

Anurag Uniyal


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

like image 33
artdanil Avatar answered Oct 31 '22 03:10

artdanil


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.

like image 21
Sharad Avatar answered Oct 31 '22 02:10

Sharad