测试按键检测代码

2+
这个程序单击一下会停止画画,然后再单击一下又会继续移动
from turtle import *

screen = Screen()

running = True
def f():
    if running:
        fd(50)
        lt(60)
    screen.ontimer(f, 250)
f()

def flip(x,y):
    global running
    running = not running
screen.onclick(flip)
screen.mainloop()

2+

发表评论