Gordon_H
unread,Dec 15, 2010, 11:31:02 PM12/15/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to wx-users
I am relatively new to wx, using Python. I have an application that
uses gauges, and would look much better if the color of the bar could
be changed. To test this, I modified the simple "gauge.py" from the
"wxPython in Action" book. I wanted to make the gauge red, but it
remains stubbornly green- even though Python does not report an error
from the SetForeGroundColour method. I am using Python 2.7, latest as
of 11/27/2010, and latest wxPython (2.8.1). I have Googled
extensively- it appears many people have encountered the same problem,
but I have not seen a solution or work-around. I am running on Win 7
home edition. I appear to have the latest version of comctl32.dll. Any
thoughts would be appreciated.
Code:
import wx
class GaugeFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, 'Gauge Example',
size=(350, 150))
panel = wx.Panel(self, -1)
self.count = 0
self.gauge = wx.Gauge(panel, -1, 50, (20, 50), (250, 25))
self.gauge.SetBezelFace(3)
self.gauge.SetShadowWidth(3)
self.gauge.SetForegroundColour('red') #
<<<<<this line added
self.Bind(wx.EVT_IDLE, self.OnIdle)
def OnIdle(self, event):
self.count = self.count + 1
if self.count >= 50:
self.count = 0
self.gauge.SetValue(self.count)
if __name__ == '__main__':
app = wx.PySimpleApp()
GaugeFrame().Show()
app.MainLoop()