我在Python中的龟程序就像点击它一样

时间:2016-11-01 23:52:24

标签: python turtle-graphics

import turtle

window = turtle.Screen()

pen = turtle.Turtle()

def star():

    pen.forward(100); 

turtle.onscreenclick(star())

window.mainloop()

我对turtle非常陌生,而python本身,我只是使用了我在python网站上找到的一些文档,但是当我运行这个程序时,它运行我的函数星,甚至没有点击屏幕。这个程序的最终目标是让我点击它然后运行该功能,然后如果我再次点击屏幕将清除,该功能将再次运行。 谢谢你的帮助!

1 个答案:

答案 0 :(得分:0)

你需要将启动函数的引用传递给onscreenclick,并使start开始接受两个参数:

def star(x,y):

    pen.forward(100);

turtle.onscreenclick(star)
相关问题