tkinter progress bar

Christian Gollwitzer auriocus at
Tue Jul 23 10:43:02 CEST 2013

Am 23.07.13 08:52, schrieb hsiwrek at
> 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.


More information about the Python-list mailing list