import turtle
def click(x, y):
turtle.goto(x,y)
s = turtle.getscreen()
s.onclick(click)
turtle.mainloop()
离线
import turtle
def leftclick(x, y):
print("left click")
turtle.pendown()
turtle.goto(x,y)
def rightclick(x, y):
print("right click")
turtle.penup()
turtle.goto(x,y)
screen = turtle.getscreen()
screen.onclick(leftclick, btn=1)
screen.onclick(rightclick, btn=3)
turtle.mainloop()
https://docs.python.org/3.7/library/turtle.html
搞定了, onclick 的第二个参数是 3 则是右击, 1 是左击, 在右击的时候执行 penup 操作即可.
离线