Python 3.0 using turtle.onclick

前端 未结 6 1741
梦毁少年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:23

    Python 3.7 version.

    import turtle as t
    
    def click(x,y):
      print('Clicked:', x, y)
    
    def main():
      s = t.Screen()
      s.onclick(click)
    
      s.mainloop()
    
    main()
    

    Note that the printing takes place at the console, not on Turtle.

提交回复
热议问题