> waiting = False
> 
> 
> 
> def clicked(x, y):
> 
>     global waiting
> 
>     print('clicked at %f %f' % (x,y))
> 
>     waiting = False
> 
>     return
> 
> 
> 
> def wait_for_click(s):
> 
>     global waiting
> 
>     waiting = True
> 
>     s.listen()
> 
>     while waiting:
> 
>         time.sleep(1)
> 
>     return
> 
> 
> 
> 
> 
> ...
> 
> t = turtle.Pen()
> 
> s = turtle.Screen()
> 
> ...
> 
> traverse.plot(s, t, "black", scale, adjx, adjy)
> 
> wait_for_click(s)
> 
> bowditch.plot(s, t, "red", scale, adjx, adjy)
> 
> wait_for_click(s)
> 
> transit.plot(s, t, "blue", scale, adjx, adjy)
> 
> wait_for_click(s)

Note that the code you posted does not call onclick().  Globals are confusing 
IMHO.  Code becomes cleaner and easier to write and read when you become 
familiar with classes.

import turtle

class TurtleTest():
    def __init__(self):
        self.ctr=0
  
        t = turtle.Turtle() 
        s = turtle.Screen() 
        s.onclick(self.clicked)
        turtle.mainloop()

    def clicked(self, x, y):
        print self.ctr
        if 0 == self.ctr:
            self.first() 
        elif 1 == self.ctr:
            self.second()      
        elif 2 == self.ctr:
            self.third()

        self.ctr += 1

    def first(self):
        print "first called"

    def second(self):
        print "second called"

    def third(self):
        print "third called"

TT = TurtleTest()
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to