0
import sys
import time
from tkinter import *
from tkinter import messagebox
Gui = Tk()
Gui.title("Exercise Timer")
def jesse(derp):
x=derp
test = 0
while x>=0 and x<=derp:
if test == 0:
Gui.after(1000,makeLabel(x))
x= x-1
if x==0:
test = 1
if test == 1:
if x == 0:
Gui.after(1000,makeLabel("brk pls"))
x=x+1
else:
Gui.after(1000,makeLabel(x))
x=x+1
def makeLabel(texts):
Gui.update()
newlab = Label(text=texts).pack()
def stop():
Gui.destroy()
mbutton = Button(text="10 seconds",command = lambda: jesse(10)).pack()
mbutton = Button(text="20 seconds",command = lambda: jesse(20)).pack()
mbutton = Button(text="30 seconds",command = lambda: jesse(30)).pack()
mbutton = Button(text="quit",fg="red",command = lambda: stop()).pack()
Gui.mainloop()
sys.exit()
对不起,如果这是一个愚蠢的问题,我刚开始学习Python。基本上我的计划是从一个数字倒数,然后每1秒计数一次显示下一个数字。除了当我关闭它时,它一切正常。它关闭,但函数jesse()继续前进,出现错误后会弹出一个窗口,只显示下一个数字,即使我点击了退出按钮或窗口x按钮。在Python GUI更新中遇到了一些麻烦