我只是一些代码,将函数绑定到鼠标点击turtle图形屏幕上:
import turtle
wn = turtle.Screen()
def token_move(x,y):
turtle.goto(x,y)
position = [turtle.xcor(), turtle.ycor()]
return position
token = turtle.Turtle()
wn.onscreenclick(token_move)
现在我的问题是,我需要海龟在鼠标点击后的坐标,这样我就可以在程序的其余部分使用它,但是因为它绑定到onscreenclick()事件,所以不能从token_move返回任何值。我试着把最后一行改成:
^{pr2}$但也没有运气。任何帮助都将不胜感激!在
目前没有回答
相关问题 更多 >
编程相关推荐