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更新中遇到了一些麻煩