Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #38224
| From | Adam Funk <a24061@ducksburg.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Detecting a click on the turtle screen when the turtle isn't doing anything? |
| Date | 2013-02-05 19:45 +0000 |
| Organization | $CABAL |
| Message-ID | <e348u9x18o.ln2@news.ducksburg.com> (permalink) |
| References | <5id7u9x7rd.ln2@news.ducksburg.com> |
On 2013-02-05, Adam Funk wrote:
> 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()
Oops, I snipped out two important lines:
#v+
s.onclick(clicked, btn=1)
wait_for_click(s, t)
#v-
> ...
> 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
>
>
--
Master Foo said: "A man who mistakes secrets for knowledge is like
a man who, seeking light, hugs a candle so closely that he smothers
it and burns his hand." --- Eric Raymond
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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