Python 3.0 using turtle.onclick

前端 未结 6 1742
梦毁少年i
梦毁少年i 2020-12-04 03:51

So here is my problem, I have to make a picture for my CS class and it is really frustrating estimating in turtle. I planed to use .onclick() to show me to position.

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-04 04:24

    You need to use the Screen class. However, if you want to stay away from OOP, you can use the built-in method turtle.onscreenclick(func).

    Replace

    def main():
        t.onclick(getPos)
        t.mainloop()
    main()
    

    with

    def main():
        t.onscreenclick(getPos)
        t.mainloop()
    main()
    

提交回复
热议问题