简体   繁体   中英

How to create progress bar with status?

I want to create a progress bar (GUI) in python. I am not sure how to do this in graphical version

I want it to print status in the output box too.

I am using progressbar2 right now

So here is my code:

import time
import progressbar

for i in progressbar.progressbar(range(100)):
    time.sleep(0.02)

Here is a small example for you to add progress bar in gui with status

from tkinter import *
from tkinter.ttk import *
import time
root=Tk()
root.title("hi")
root.geometry("600x400")

a=IntVar()  
prog=Progressbar(root,orient=HORIZONTAL,length= 300,mode = 'determinate' )
def step():
    for x in range(5):
    
        prog['value']+=20
        a.set(prog['value'])
    
        root.update_idletasks()
        time.sleep(1)
prog.pack(pady=20)

butn=Button(root,text='Progress',command=step).pack(pady=20)
lb=Entry(root,textvar=a).pack(pady=20)
root.mainloop()

It think it may help you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM