| | |
wxpython labels
Thread Solved |
I am trying things with wxStaticText (a label). I can chnage background colour, but not the text colour:
How to change text colour?
Python Syntax (Toggle Plain Text)
import wx class MyPanel(wx.Panel): def __init__(self, parent, id): wx.Panel.__init__(self, parent, id) str1 = "Camembert cheese is the best!" self.label1 = wx.StaticText(self, -1, str1 , wx.Point(15, 30)) self.label2 = wx.StaticText(self, -1, str1 , wx.Point(15, 50)) self.label2.SetBackgroundColour("Yellow") #self.label2.SetTextColour("blue") # gives error! app = wx.PySimpleApp() myframe = wx.Frame(None, -1, "wxPython Labels", size = (330, 150)) MyPanel(myframe, -1) myframe.Show(1) app.MainLoop()
For labels you have to use SetForegroundColour ...
Python Syntax (Toggle Plain Text)
import wx class MyPanel(wx.Panel): def __init__(self, parent, id): wx.Panel.__init__(self, parent, id) str1 = "Camembert cheese is the best!" self.label1 = wx.StaticText(self, -1, str1 , wx.Point(15, 30)) self.label2 = wx.StaticText(self, -1, str1 , wx.Point(15, 50)) self.label2.SetBackgroundColour("yellow") # use SetForegroundColour() and not SetTextColour() self.label2.SetForegroundColour("blue") app = wx.PySimpleApp() myframe = wx.Frame(None, -1, "wxPython Labels", size = (330, 150)) MyPanel(myframe, -1) myframe.Show(1) app.MainLoop()
May 'the Google' be with you!
![]() |
Similar Threads
- Starting Python (Python)
- no WxPython here? (Python)
- Axis Labels (Java)
- return address labels (Windows NT / 2000 / XP)
Other Threads in the Python Forum
- Previous Thread: pyWin32 & wxPython
- Next Thread: writing swap function in Python
| Thread Tools | Search this Thread |
abrupt ansi anti approximation assignment avogadro backend beginner binary bluetooth calculator character cmd code customdialog cx-freeze data decimals dictionaries dictionary directory dynamic error examples exe file float format function gnu graphics gui heads homework http ideas import input itunes java launcher leftmouse line linux list lists loop module mouse number numbers output parsing path pointer port prime programming progressbar projects push py2exe pygame pyglet pyqt python random recursion schedule screensaverloopinactive script scrolledtext sqlite ssh statistics string strings sudokusolver sum table terminal text thread threading time tlapse tricks tuple tutorial twoup ubuntu unicode urllib urllib2 variable ventrilo wikipedia write wxpython xlib






