Python Turtle

Does anybody know how to get the coordinates of a click on python turtle graphics? all I need is to be able to get the x of where someone clicks, and throw out the y. The turtle documentation page at https://docs.python.org/2/library/turtl … le.onclick says to use function onclick, and it will wait until someone clicks and then run the function in it’s argument place, as long as that function has two arguments that it uses but doesn’t have the parentheses in the onclick’s parentheses. I am trying to first use the example code given in the documentation:

>>> def turn(x, y):
...     left(180)
...
>>> onclick(turn)  # Now clicking into the turtle will turn it.
>>> onclick(None)  # event-binding will be removed

of course, slightly edited to actually work:

import turtle
win = turtle.Screen()
turtle = turtle.Turtle()
def turn(x, y):
    turtle.left(180)

win.onclick(turn)  # Now clicking into the turtle will turn it.
win.onclick(None)  # event-binding will be removed

But nothing happens. if I click the screen enough, the turtle graphics eventually stops responding.

I tried putting the “win.onclick” part in a forever loop, nothing changed. but when I had in print “looping” at the start of loop, I found that the onclick function does not wait. the monitor kept reprinting

looping

looping

looping

over and over again at the speed of sound.

so my question is:

how to (actually) get the x of the click?

and

what am I doing wrong?

Thank you!

The Hermanoid