This works for me

from progress import PB
from time import sleep

def main():
    bar = PB(300, 50)
    bar.open()
    for i in range(10):
        bar.update((10.0 * i) / 100)
        sleep(1)
    bar.close()

main()

Also, you could replace self.__root = Tkinter.Toplevel() by self.__root = Tkinter.Tk() (or add an argument to __init__ to chose between the 2 classes)

This works for me

from progress import PB
from time import sleep

def main():
    bar = PB(300, 50)
    bar.open()
    for i in range(10):
        bar.update((10.0 * i) / 100)
        sleep(1)
    bar.close()

main()

Also, you could replace self.__root = Tkinter.Toplevel() by self.__root = Tkinter.Tk() (or add an argument to __init__ to chose between the 2 classes)

Thanks for your help! My problem was at updating the bar.

Add a print statement to see what is going on

from progress import PB
from time import sleep
 
def main():
    bar = PB(300, 50)
    bar.open()
    for i in range(10):
        print "updating bar by",  (10.0 * i) / 100
        bar.update((10.0 * i) / 100)
        sleep(1)
    bar.close()
 
main()

Edited 7 Years Ago by woooee: n/a

If you use Python 3.1.1, then you can simply use the Tkinter module ttk that ships with it ...

# explore the ttk.Progressbar of the Tkinter module ttk
# ttk is included with Python 3.1.1

import tkinter as tk
from tkinter import ttk

def click(event):
    # can be a float
    increment = 4
    pbar.step(increment)


root = tk.Tk()
root.title('ttk.Progressbar')

pbar = ttk.Progressbar(root, length=300)
pbar.pack(padx=5, pady=5)

btn = tk.Button(root, text="Click to advance progress bar")
# bind to left mouse button click
btn.bind("<Button-1>", click)
btn.pack(pady=10)

root.mainloop()

Edited 7 Years Ago by vegaseat: tkk --&gt; ttk

This question has already been answered. Start a new discussion instead.