wxpython labels

Thread Solved

Join Date: Jul 2005
Posts: 1,221
Reputation: bumsfeld will become famous soon enough bumsfeld will become famous soon enough 
Solved Threads: 137
bumsfeld's Avatar
bumsfeld bumsfeld is offline Offline
Nearly a Posting Virtuoso

wxpython labels

 
0
  #1
Nov 23rd, 2005
I am trying things with wxStaticText (a label). I can chnage background colour, but not the text colour:
  1. import wx
  2.  
  3. class MyPanel(wx.Panel):
  4. def __init__(self, parent, id):
  5. wx.Panel.__init__(self, parent, id)
  6. str1 = "Camembert cheese is the best!"
  7. self.label1 = wx.StaticText(self, -1, str1 , wx.Point(15, 30))
  8. self.label2 = wx.StaticText(self, -1, str1 , wx.Point(15, 50))
  9. self.label2.SetBackgroundColour("Yellow")
  10. #self.label2.SetTextColour("blue") # gives error!
  11.  
  12.  
  13. app = wx.PySimpleApp()
  14. myframe = wx.Frame(None, -1, "wxPython Labels", size = (330, 150))
  15. MyPanel(myframe, -1)
  16. myframe.Show(1)
  17. app.MainLoop()
How to change text colour?
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 3,982
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 925
Moderator
vegaseat's Avatar
vegaseat vegaseat is online now Online
DaniWeb's Hypocrite

Re: wxpython labels

 
0
  #2
Nov 26th, 2005
For labels you have to use SetForegroundColour ...
  1. import wx
  2.  
  3. class MyPanel(wx.Panel):
  4. def __init__(self, parent, id):
  5. wx.Panel.__init__(self, parent, id)
  6. str1 = "Camembert cheese is the best!"
  7. self.label1 = wx.StaticText(self, -1, str1 , wx.Point(15, 30))
  8. self.label2 = wx.StaticText(self, -1, str1 , wx.Point(15, 50))
  9. self.label2.SetBackgroundColour("yellow")
  10. # use SetForegroundColour() and not SetTextColour()
  11. self.label2.SetForegroundColour("blue")
  12.  
  13.  
  14. app = wx.PySimpleApp()
  15. myframe = wx.Frame(None, -1, "wxPython Labels", size = (330, 150))
  16. MyPanel(myframe, -1)
  17. myframe.Show(1)
  18. app.MainLoop()
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Python Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC