ProgressBar is a widget that allows monotonic or oscillating progress meters. The code below creates an oscillating progress bar, handy for events whose duration you are not sure about. You would have to provide a way to stop the progress bar, however.

   1 #!/usr/bin/python24
   2 
   3 from Tkinter import *
   4 from bwidget import *
   5 
   6 t = Tk()
   7 progval = IntVar(t)
   8 progmsg = StringVar(t); progmsg.set("Compute in progress...")
   9 b = Button(t, relief=LINK, text="Quit (using bwidget)", command=t.destroy)
  10 b.pack()
  11 c = ProgressDialog(t, title="Please wait...",
  12                    type="infinite",
  13                    width=20,
  14                    stop="Stop",
  15                    textvariable=progmsg,
  16                    variable=progval,
  17                    command=lambda: c.destroy()
  18                    )
  19 def update_progress():
  20        progval.set(2)
  21        c.after(20, update_progress)
  22 
  23 update_progress()
  24 t.mainloop()

Screenshot:

bwProgressBar2.png

tkinter: ProgressBar (last edited 2010-07-26 11:59:12 by localhost)