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


Groups > comp.lang.python > #51075

Re: tkinter progress bar

From Christian Gollwitzer <auriocus@gmx.de>
Newsgroups comp.lang.python
Subject Re: tkinter progress bar
Date 2013-07-23 10:43 +0200
Organization A noiseless patient Spider
Message-ID <kslfb0$pi0$1@dont-email.me> (permalink)
References <e1aae2d8-4e27-4644-8119-173fd8f5b47e@googlegroups.com>

Show all headers | View raw


Am 23.07.13 08:52, schrieb hsiwrek@walla.com:
> Hi,
> 	
> How can I add a tkinter progress bar in python 3.2 to start before a loop and end after it. I am looking for a very simple solution.
>
> def MyFunc():
> Start progress bar
>
> for fileName in fileList:
> …
>
> End progress bar
>

1. There is a progress bar widget in ttk. At the beginning, you set 
maximum to the number of files in your list

2. In the loop, you set "value" of the progressbar to the current file 
number. You can also attach a variable

3. The bar is only redrawn when you process events. The simplest way to 
do this is by calling update() on the progress bar, which processes all 
pending events. Despite of it looking like a method, update() is really 
a global function within Tcl and updates all widgets in your interface. 
You must make sure, therefore, that the user does not trigger another 
event which interferes with your download, such as pressing the button 
for starting it again. The easiest way is to disable the button at the 
begin and reenable it at the end.

4. If processing of a single file takes a long time, the only way to 
have the GUI responsive is to put the work in a background thread. That 
seems to be more involved.

	Christian

Back to comp.lang.python | Previous | NextPrevious in thread | Next 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