Marquee style progressbar in wxPython

Posted by Mridang Agarwalla on Stack Overflow See other posts from Stack Overflow or by Mridang Agarwalla
Published on 2010-05-18T10:36:29Z Indexed on 2010/05/18 20:10 UTC
Read the original article Hit count: 496

Filed under:
|

Hi,

Could anyone tell me how to implement a marquee style progress bar in wxPython? As stated on MSDN:

you can animate it in a way that shows activity but does not indicate what proportion of the task is complete.

Thank you.

alt text

I tried this but it doesn't seem to work. The timer ticks but the gauge doesn't scroll. Any help?

import wx
import time

class MyForm(wx.Frame):

    def __init__(self):
        wx.Frame.__init__(self, None, wx.ID_ANY, "Timer Tutorial 1",
                                   size=(500,500))

        # Add a panel so it looks the correct on all platforms
        panel = wx.Panel(self, wx.ID_ANY)

        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.update, self.timer)
        self.gauProgress = wx.Gauge(panel, range=1000, pos=(30, 50), size=(440, 20))
        self.toggleBtn = wx.Button(panel, wx.ID_ANY, "Start")
        self.toggleBtn.Bind(wx.EVT_BUTTON, self.onToggle)

    def onToggle(self, event):
        btnLabel = self.toggleBtn.GetLabel()
        if btnLabel == "Start":
            print "starting timer..."
            self.timer.Start(1000)
            self.toggleBtn.SetLabel("Stop")
        else:
            print "timer stopped!"
            self.timer.Stop()
            self.toggleBtn.SetLabel("Start")

    def update(self, event):
        print "\nupdated: ",
        print time.ctime()
        self.gauProgress.Pulse()

# Run the program
if __name__ == "__main__":
    app = wx.PySimpleApp()
    frame = MyForm().Show()
    app.MainLoop()

© Stack Overflow or respective owner

Related posts about python

Related posts about wxpython