Hello!
I need to create a progress bar and up to this our this class http://code.activestate.com/recipes/492230/#clast is the best class that fits my needs.
I posted my problem at comments.
Thanks,
Danci Emanuel
Hello!
I need to create a progress bar and up to this our this class http://code.activestate.com/recipes/492230/#clast is the best class that fits my needs.
I posted my problem at comments.
Thanks,
Danci Emanuel
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()
byself.__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()
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()
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.