Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #38191

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

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Adam Funk <a24061@ducksburg.com>
Newsgroups comp.lang.python
Subject Detecting a click on the turtle screen when the turtle isn't doing anything?
Date Tue, 05 Feb 2013 13:20:37 +0000
Organization $CABAL
Lines 54
Message-ID <5id7u9x7rd.ln2@news.ducksburg.com> (permalink)
X-Trace individual.net 03OV8x18JAcXIQAm2K7heQ0XH/s0PXP2iocksYlxYpbGb6uUrzSyREo0K1TqjkofZ+
X-Orig-Path news.ducksburg.com!not-for-mail
Cancel-Lock sha1:hfnjAU1HSz70gmzzSCBRMkuTYZ0= sha1:6cc6K/WoWasPG/Y16KHV3rseLfw=
User-Agent slrn/1.0.1 (Linux)
Xref csiph.com comp.lang.python:38191

Show key headers only | View raw


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:

#v+
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)
#v-


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
anything?


[1] <http://csil-web.cs.surrey.sfu.ca/cmpt120fall2010/wiki/IntroToEventHandling/>


Thanks,
Adam


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

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Detecting a click on the turtle screen when the turtle isn't doing anything? Adam Funk <a24061@ducksburg.com> - 2013-02-05 13:20 +0000
  Re: Detecting a click on the turtle screen when the turtle isn't doing anything? woooee@gmail.com - 2013-02-05 10:08 -0800
    Re: Detecting a click on the turtle screen when the turtle isn't doing anything? Adam Funk <a24061@ducksburg.com> - 2013-02-05 19:58 +0000
      Re: Detecting a click on the turtle screen when the turtle isn't doing anything? Dave Angel <d@davea.name> - 2013-02-05 16:55 -0500
        Re: Detecting a click on the turtle screen when the turtle isn't doing anything? Adam Funk <a24061@ducksburg.com> - 2013-02-06 21:46 +0000
  Re: Detecting a click on the turtle screen when the turtle isn't doing anything? Adam Funk <a24061@ducksburg.com> - 2013-02-05 19:45 +0000
    Re: Detecting a click on the turtle screen when the turtle isn't doing anything? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-02-05 16:54 -0500
      Re: Detecting a click on the turtle screen when the turtle isn't doing anything? Adam Funk <a24061@ducksburg.com> - 2013-02-06 21:52 +0000

csiph-web