Tkinter Wiki   ProgressBar UserPreferences
 
HelpContents FindPage Diffs Info Edit Subscribe XML Print View

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 
  2 
  3 
  4 
  5 
  6 
  7 
  8 
  9 
 10 
 11 
 12 
 13 
 14 
 15 
 16 
 17 
 18 
 19 
 20 
 21 
 22 
 23 
 24 
#!/usr/bin/python24

from Tkinter import *
from bwidget import *

t = Tk()
progval = IntVar(t)
progmsg = StringVar(t); progmsg.set("Compute in progress...")
b = Button(t, relief=LINK, text="Quit (using bwidget)", command=t.destroy)
b.pack()
c = ProgressDialog(t, title="Please wait...",
                   type="infinite",
                   width=20,
                   stop="Stop",
                   textvariable=progmsg,
                   variable=progval,
                   command=lambda: c.destroy()
                   )
def update_progress():
       progval.set(2)
       c.after(20, update_progress)

update_progress()
t.mainloop()

Screenshot:

bwProgressBar2.png

PythonPowered