Detecting a click on the turtle screen when the turtle isn't doing anything?

Adam Funk a24061 at
Tue Feb 5 14:20:37 CET 2013

I'm trying to get a program to do some plotting with turtle graphics,
then wait for the user to click on the graphics window, then do some
more plotting, &c.  So far I have the following, which doesn't work:

waiting = False

def clicked(x, y):
    global waiting
    print('clicked at %f %f' % (x,y))
    waiting = False

def wait_for_click(s):
    global waiting
    waiting = True
    while waiting:

t = turtle.Pen()
s = turtle.Screen()
traverse.plot(s, t, "black", scale, adjx, adjy)
bowditch.plot(s, t, "red", scale, adjx, adjy)
transit.plot(s, t, "blue", scale, adjx, adjy)

Each of my plot(..) calls does some turtle movement, and I want the
program to sit and wait for the user to click the graphics window,
then add the next plot.  I've played around with some event handling
examples I found [1], and concluded that the onclick binding only
works while the turtle is doing something.  Is that correct?  Is there
a way to wait for the click & hear it while the turtle is not doing

[1] <>


But the government always tries to coax well-known writers into the
Establishment; it makes them feel educated.         [Robert Graves]

More information about the Python-list mailing list