As a workaround, you could sub-class PyGauge and override its SetValue method. It appears to work in the example below, but I haven’t tested all of the class’s functionality to see if it has broken anything.
import wx
import wx.lib.agw.pygauge as PG
class MyPyGauge(PG.PyGauge):
def SetValue(self, value):
super().SetValue(value)
self.Refresh()
class MyFrame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, -1, "PyGauge")
self.panel = wx.Panel(self)
self.gauge = MyPyGauge(self.panel, -1, size=(200, 25), style=wx.GA_HORIZONTAL)
self.gauge.SetBackgroundColour(wx.WHITE)
self.gauge.SetBorderColor(wx.BLACK)
self.gauge.SetRange(100)
self.gauge.SetValue(0)
button_sizer = wx.BoxSizer(wx.HORIZONTAL)
for v in (0, 25, 50, 100):
b = wx.Button(self.panel, -1, str(v), size=(50, -1))
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
button_sizer.Add(b, 0, wx.RIGHT, 8)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.gauge, 0, wx.ALIGN_CENTER | wx.ALL, 20)
sizer.Add(button_sizer, 0, wx.ALIGN_CENTER | wx.ALL, 20)
self.panel.SetSizer(sizer)
sizer.Layout()
def OnButton(self, event):
b = event.GetEventObject()
v = int(b.GetLabel())
self.gauge.SetValue(v)
app = wx.App(0)
frame = MyFrame(None)
frame.Show()
app.MainLoop()