Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #38305
| 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-06 21:46 +0000 |
| Organization | $CABAL |
| Message-ID | <9ivau9xovn.ln2@news.ducksburg.com> (permalink) |
| References | <5id7u9x7rd.ln2@news.ducksburg.com> <8e3f3198-3657-4abc-b367-06479a561e41@googlegroups.com> <6s48u9x49o.ln2@news.ducksburg.com> <mailman.1391.1360101376.2939.python-list@python.org> |
On 2013-02-05, Dave Angel wrote:
> I'm no fan of Java. But it's not about a "main" method, it's about
> sharing data between functions. Most of the time non-constant globals
> are a mistake. If the data can't be passed as an argument, then it
> should probably be part of the instance data of some class. Which class
> is a design decision, and unlike Java, I wouldn't encourage writing a
> class for unrelated functions, just to bundle them together.
Well, I understand the OO principle there, but it seems practical to
accept a few global variables in the "main" code of a program.
Anyway...
> Anyway, back to your problem. Since your code doesn't have threads, it
> must have an event loop somewhere. Event loops don't coexist at all
> well with calls to sleep().
>
> while waiting:
> time.sleep(1)
>
> If you start that code with waiting being true, it will never terminate.
Right. But the following *does* work (although it's probably
offensive):
#v+
def wait_for_click(s, t):
global waiting
waiting = True
s.listen()
t.hideturtle()
t.penup()
while waiting:
t.forward(5)
t.right(5)
return
#v-
--
A lot of people never use their intiative because no-one
told them to. --- Banksy
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