0
I am making a mini-program to be used in the working hours/study style the Pomodoro method. I made it very simple, fast, but when I press to start, the program hangs exactly the time that was put and only comes back when everything ended, to try to find the error I left with 3 seconds each interval and time of service, then it stands still until it finishes everything. There are some visual changes that should occur on the tele, as show the cycles and what stage is, but nothing moves, and only comes back when everything Zera. Follow the code below:
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 a characteristic of Tkinter, which doesn’t allow you to keep fiddling with your look constantly. Or is there something wrong that I’m not noticing?
Thanks....
Wow, really cool, I didn’t know this function of Tkinter. Excellent, my Sleep exchange was very suspicious of being the problem kkkk. I’m gonna do a few extra things on him, but there you go. The people who want to make their tasks more productive, already have a program to let rolling while working/ study. Thanks!
– user86267