为此循环找到解决方案的问题。所以该项目是一个倒数计时器,它只工作一次,然后再拒绝工作。我正在使用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')
答案 0 :(得分:-1)