Python 3.0 using turtle.onclick

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

    I have a small child coder but I learn a lot.

    I like to do coding only that for somebody say that you created good but I also love to share out what I learn.

    You came here for codes onclick codes are here:

    You need to do the following:

    # import package 
    import turtle 
       
    # screen object 
    wn = turtle.Screen() 
      
    # method to perform action 
    def fxn(x, y): 
      turtle.goto(x, y) 
      turtle.write(str(x)+","+str(y)) 
      
    # onclick action  
    wn.onclick(fxn) 
    wn.mainloop()`
    

    Now, just click on the screen and see the magic

提交回复
热议问题