0
找到此循環的解決方案的問題。所以該項目是一個倒數計時器,它只能工作一次,然後拒絕再次工作。我正在使用graphics.py擴展名,並試圖在按下按鈕時做一些事情,然後當我再次按下它時,它會循環備份並重新啓動。我已經得到了第一部分,如下所示,但無法找出迴路部分。在Python中按下按鈕的循環(graphics.py)
while True:
try:
point = win.checkMouse()
except GraphicsError:
return
if point == None:
continue
if is_clicked(point, start_button):
start_time = user_entry.getText()
seq = ("0", start_time)
if start_time[0] != '0':
start_time = ''.join(seq)
start_seconds = convert_to_seconds(start_time)
for second in range(start_seconds, -1, -1):
clock_time = convert_to_clock(second)
clock.setText(clock_time)
sleep(1)
flash(win, 5)
elif is_clicked(point, exit_button):
win.close()
return
else:
win.setBackground('red')
sleep(.2)
win.setBackground('white')