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


Groups > comp.lang.python > #38235

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

Date 2013-02-05 16:55 -0500
From Dave Angel <d@davea.name>
Subject Re: Detecting a click on the turtle screen when the turtle isn't doing anything?
References <5id7u9x7rd.ln2@news.ducksburg.com> <8e3f3198-3657-4abc-b367-06479a561e41@googlegroups.com> <6s48u9x49o.ln2@news.ducksburg.com>
Newsgroups comp.lang.python
Message-ID <mailman.1391.1360101376.2939.python-list@python.org> (permalink)

Show all headers | View raw


On 02/05/2013 02:58 PM, Adam Funk wrote:
> On 2013-02-05, woooee@gmail.com wrote:
>
>>    <SNIP>
>
>> Globals are
>>   confusing IMHO.  Code becomes cleaner and easier to write and read
>>   when you become familiar with classes.
>
<snip>
>   If I have to write a class just to create
> one instance of it & call the main() method, I might as well use Java!
> ;-)
>

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.


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.

I don't know turtle graphics, but if it's got an event loop, then you 
can't write your program procedurally.  A function called 
"wait_for_click()" is nonsensical.


-- 
DaveA

Back to comp.lang.python | Previous | NextPrevious in thread | Next 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