Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #51088

Re: tkinter progress bar

References <e1aae2d8-4e27-4644-8119-173fd8f5b47e@googlegroups.com> <kslfb0$pi0$1@dont-email.me> <fe5a2cf6-2135-4d93-947a-bf9a51a3c15c@googlegroups.com>
Date 2013-07-23 09:27 -0400
Subject Re: tkinter progress bar
From Jason Swails <jason.swails@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.5007.1374586082.3114.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On Tue, Jul 23, 2013 at 5:38 AM, <hsiwrek@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

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

tkinter progress bar hsiwrek@walla.com - 2013-07-22 23:52 -0700
  Re: tkinter progress bar Christian Gollwitzer <auriocus@gmx.de> - 2013-07-23 10:43 +0200
    Re: tkinter progress bar hsiwrek@walla.com - 2013-07-23 02:38 -0700
      Re: tkinter progress bar Jason Swails <jason.swails@gmail.com> - 2013-07-23 09:27 -0400

csiph-web