Advertisement
MizunoBrasil

Python Progress Bar

Jul 5th, 2023
979
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.82 KB | None | 0 0
  1. Python Progress Bar
  2. Credits to Bro Code
  3. Youtube Channell: https://www.youtube.com/watch?v=0WRMYdOwHYE
  4.  
  5.        
  6. from tkinter import *
  7. from tkinter.ttk import *
  8. import time
  9.  
  10. def start():
  11.     GB = 100
  12.     download = 0
  13.     speed = 1
  14.     while(download<GB):
  15.         time.sleep(0.05)
  16.         bar['value']+=(speed/GB)*100
  17.         download+=speed
  18.         percent.set(str(int((download/GB)*100))+"%")
  19.         text.set(str(download)+"/"+str(GB)+" GB completed")
  20.         window.update_idletasks()
  21.  
  22. window = Tk()
  23.  
  24. percent = StringVar()
  25. text = StringVar()
  26.  
  27. bar = Progressbar(window,orient=HORIZONTAL,length=300)
  28. bar.pack(pady=10)
  29.  
  30. percentLabel = Label(window,textvariable=percent).pack()
  31. taskLabel = Label(window,textvariable=text).pack()
  32.  
  33. button = Button(window,text="download",command=start).pack()
  34.  
  35. window.mainloop()
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement