tkinter progress bar

Jason Swails jason.swails at gmail.com
Tue Jul 23 15:27:59 CEST 2013


On Tue, Jul 23, 2013 at 5:38 AM, <hsiwrek at walla.com> wrote:

> Dear Christian,
>
> Thanks for the help. Can you please add a source example as I am new with
> Tkinter.
>

 http://docs.python.org/2/library/ttk.html#progressbar

You can do something like this:

#!/usr/bin/env python

import Tkinter as tk
import ttk
import time

class MainApp(tk.Frame):

   def __init__(self, master):
      tk.Frame.__init__(self, master)
      self.progress = ttk.Progressbar(self, maximum=10)
      self.progress.pack(expand=1, fill=tk.BOTH)
      self.progress.bind("<Button-1>", self._loop_progress)

   def _loop_progress(self, *args):
      for i in range(10):
         self.progress.step(1)
         # Necessary to update the progress bar appearance
         self.update()
         # Busy-wait
         time.sleep(2)


if __name__ == '__main__':
   root = tk.Tk()
   app = MainApp(root)
   app.pack(expand=1, fill=tk.BOTH)
   root.mainloop()


This is a simple stand-alone app that (just) demonstrates how to use the
ttk.Progressbar widget.

HTH,
Jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130723/47a38566/attachment.html>


More information about the Python-list mailing list