from tkinter import *
from tkinter.ttk import *
import time
root = Tk()
def butao_comando():
GB = 100
download = 0
speed = 1
while (download < GB):
time.sleep(0.05)
bar['value'] += (speed / GB) * 100
download += speed
percentagem.set(str(int((download / GB) * 100)) + "%")
root.update_idletasks()
root.title("Barra")
root.geometry("450x200")
root.resizable(False,False)
bar = Progressbar(root,orient=HORIZONTAL,length=300)
bar.place(relx=0.2,rely=0.3)
percentagem = StringVar()
percentagem_texto = Label(root,textvariable=percentagem)
percentagem_texto.place(relx=0.5,rely=0.5)
butao = Button(root,text="começar a barra",command=butao_comando)
butao.place(relx=0.45,rely=0.7)
root.mainloop()
Comentários
Enviar um comentário