У меня есть этот код:
def timer():
text2['text'] = str(timer.current)
timer.current = timer.current - 1
if timer.current >= 0:
f.after(1000, timer)
def codigo():
global text2
f2=Frame(f, width=300, height=500)
f2.pack()
f2.config(bg='dark grey')
text2=Label(f, text=spin.get(), font=('Arial Bold', 90), bg=('dark grey'))
text2.place(x=80, y=200)
timer.current = int(spin.get())
timer()
text3=Label(f, text = int(spin4.get()), font=('Arial Bold', 30), bg=('dark grey'))
text3.place(x=200, y=350)
text4=Label(f, text=spin4.get(), font=('Arial Bold', 30), bg=('dark grey'))
text4.place(x=170, y=400)
text5=Label(f, text='Ejercicios:', font=('Arial Bold', 30), bg=('dark grey'))
text5.place(x=5, y=350)
text6=Label(f, text='Rondas:', font=('Arial Bold', 30), bg=('dark grey'))
text6.place(x=5, y=400)
def ejercicio():
#here is the problem, I think
if text2 == 0:
text2(text=spin4.get())
timer.current(int(spin4.get()))
btn1 = tk.Button(f, text='Empezar', command=codigo, bg=('dark grey'))
btn1.pack()
btn1.place(x=150, y=150)
window.mainloop()
Проблема в text2
, когда я делаю if. Выход должен быть регрессивным таймером, начиная с spin4
, но text2
не меняется.
Я пытался написать ìnt
на if text2 == 0:
, но в любом случае не работает , Я попытался изменить if
и изменить только вывод text2
, например:
if text2 == 0:
text2(text='Hi!')
Но вывод такой же: 0