wxGauge color change

630 views
Skip to first unread message

Gordon_H

unread,
Dec 15, 2010, 11:31:02 PM12/15/10
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()

Vadim Zeitlin

unread,
Dec 16, 2010, 7:19:23 AM12/16/10
to wx-u...@googlegroups.com
On Wed, 15 Dec 2010 20:31:02 -0800 (PST) Gordon_H <gor...@alpharadioproducts.com> wrote:

G> I am relatively new to wx, using Python. I have an application that
G> uses gauges, and would look much better if the color of the bar could
G> be changed.

This can't be done under Windows, it's a native control limitation and I'm
not aware of any simple workaround for this.

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/

Gordon_H

unread,
Dec 16, 2010, 1:28:39 PM12/16/10
to wx-users
Okay- thanks. At least I know to stop trying!

Gordon
>  application_pgp-signature_part
> < 1KViewDownload
Reply all
Reply to author
Forward
0 new messages