To do a mini-programinha to be used in the work / study hours style the pomodoro method. I made it very simple, quick, but when I press to start, the program locks exactly the time that was put and only comes back when everything is finished, to try to find the error I left with 3 seconds each interval and time of service, then it is stopped until finished all. In this there are some visual changes that should take place on the TV, such as showing the cycles and what stage it is, but nothing moves, and only comes back when everything goes. Here is the code:
from tkinter import *
from time import sleep
# Action
def pomodoro():
lb_acao['text'] = 'Pomodori'
lb_acao['bg'] = 'red'
qt_ciclos = int(ed_ciclos.get())
while qt_ciclos >= 0:
lb_ciclos_restantes['text'] = qt_ciclos
sleep(3)
lb_acao['text'] = 'Intervalo'
lb_acao['bg'] = 'green'
sleep(3)
lb_acao['text'] = 'Pomodori'
lb_acao['bg'] = 'red'
qt_ciclos -= 1
win = Tk()
# Components
lb1 = Label(win, text='Tempo útil: ')
ed_tempo = Entry(win)
lb2 = Label(win, text='Tempo de intervalo: ')
ed_intervalo = Entry(win)
lb3 = Label(win, text='Quantidade de ciclos: ')
ed_ciclos = Entry(win)
btn = Button(win, text='Começar', command=pomodoro)
lb4 = Label(win, text='Ciclos restantes:')
lb_ciclos_restantes = Label(win, text='0')
lb5 = Label(win, text='Modo:')
lb_acao = Label(win, text='Preparado')
lb6 = Label(win, text='Tempo:')
lb_time = Label(win)
# GUI
lb1.grid(row=0, column=0)
ed_tempo.grid(row=0, column=1)
lb2.grid(row=1, column=0)
ed_intervalo.grid(row=1, column=1)
lb3.grid(row=2, column=0)
ed_ciclos.grid(row=2, column=1)
btn.grid(row=3, column=0, columnspan=2, sticky=W+E)
lb4.grid(row=4, column=0)
lb_ciclos_restantes.grid(row=4, column=1)
lb5.grid(row=5, column=0)
lb_acao.grid(row=5, column=1)
lb6.grid(row=6, column=0)
lb_time.grid(row=6, column=1)
# Program
win.mainloop()
So this is characteristic of tkinter, which does not allow you to constantly tinker with your look. Or is there something wrong that I'm not fixing?
Thanks ....