Core Windows/Controls → Gauge
Overview = """\
A Gauge is a horizontal or vertical bar which shows a quantity in a graphical
fashion. It is often used to indicate progress through lengthy tasks, such as
file copying or data analysis.
When the Gauge is initialized, it's "complete" value is usually set; at any rate,
before using the Gauge, the maximum value of the control must be set. As the task
progresses, the Gauge is updated by the program via the SetValue method.
This control is for use within a GUI; there is a seperate ProgressDialog class
to present the same sort of control as a dialog to the user.
"""
import wx
class Frame(wx.Frame):
def __init__(
self, parent=None, id=-1, title='Gauge', pos=wx.DefaultPosition,
size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE
):
wx.Frame.__init__(self, parent, id, title, pos, size, style)
self.SetIcon(wx.Icon('wxWidgets.ico', wx.BITMAP_TYPE_ICO))
Panel = wx.Panel(self, -1)
wx.StaticText(Panel, -1, 'wx.Gauge', (45, 15))
self.Gauge1 = wx.Gauge(Panel, -1, 100, (60, 50), (250, 25))
self.Gauge2 = wx.Gauge(Panel, -1, 100, (60, 95), (250, 25))
self.Gauge3 = wx.Gauge(Panel, -1, 100, (60, 150), (25, 250), style=wx.GA_VERTICAL)
self.Timer = wx.Timer(self)
self.Timer.Start(100)
self.Bind(wx.EVT_TIMER, self.OnTimer)
self.Count = 0
def __del__(self):
self.Timer.Stop()
def OnTimer(self, event):
self.Count += 1
if self.Count == 100:
self.Count = 0
self.Gauge1.SetValue(self.Count)
self.Gauge2.Pulse()
self.Gauge3.SetValue(self.Count)
def TestFrame():
app = wx.PySimpleApp()
frame = Frame()
frame.Centre()
frame.Show()
app.MainLoop()
if __name__ == '__main__':
TestFrame()