Python 3.0 using turtle.onclick -
so here problem, have make picture cs class , frustrating estimating in turtle. planed use .onclick() show me position.
import turtle t def getpos(x,y): print("(", x, "," ,y,")") return def main(): t.onclick(getpos) t.mainloop() main()
the turtle documentation seems onclick pass coordinates in function takes in 2 variables.
http://docs.python.org/3.1/library/turtle.html#turtle.onclick
note: works when click on arrow head, thats not want. want click other position on screen find out coordinates should send arrow head to!
any appreciated.
you need use screen class. however, if want stay away oop, can use built-in method turtle.onscreenclick(func).
replace
def main(): t.onclick(getpos) t.mainloop() main()
with
def main(): t.onscreenclick(getpos) t.mainloop() main()
Comments
Post a Comment