我一直在尝试制作这个简单的计时器,我是 python 的新手(我知道代码很乱)而且我无法让这段代码工作,任何帮助将不胜感激。
我尝试了很多方法,但不确定它们是如何工作的以及如何让它们工作。
def speedtimersub():#speed timer section
global paused
paused = True
global speedtimernumber
speedtimernumber = 0
for widgets in window.winfo_children():#selects all widgets in window
widgets.destroy()#gets rid of all widgets
def speedtimerloop():
print ("medjs")
def endspeedtimer():
paused= True
speedtimernumber = 0
def startspeedtimer():
paused = False
speedtimernumber = 0.00
speedtimerstart = Button(window, text="start", background="black", font=("Roboto", 15), fg="white",command=startspeedtimer)
speedtimerstart.place(x=235, y=600)
speedtimerend = Button(window, text="end/restart", background="black", font=("Roboto", 15), fg="white",command=endspeedtimer)
speedtimerend.place(x=435, y=600)
speedtimerpause = Button(window, text="pause/play", background="black", font=("Roboto", 15), fg="white",command=startspeedtimer)
speedtimerpause.place(x=635, y=600)
timerlabel = Label(bg="black", fg="white", text=round(speedtimernumber, 3))
timerlabel.place(x=400, y=400)
while paused == False:
time.sleep(0.01)
speedtimernumber=speedtimernumber + 0.01
timerlabel = Label(bg="black", fg="white",text=round(speedtimernumber,3))
timerlabel.place(x=400, y=400)
window.after(1, speedtimerloop)
请帮助我,我真的很想开始编码,但这真的让我失望了。