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


Groups > comp.lang.python > #38233

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

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'implements': 0.07; 'exits': 0.09; 'itself,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'def': 0.10; 'thread': 0.11; 'value.': 0.15; '"global"': 0.16; '(x,': 0.16; 'adam': 0.16; 'blocks': 0.16; 'callback)': 0.16; 'dislike': 0.16; 'echo': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:Detecting': 0.16; 'subject:screen': 0.16; 'subject:turtle': 0.16; 'subject:when': 0.16; 'threading': 0.16; 'y):': 0.16; 'feb': 0.19; 'import': 0.21; 'sets': 0.23; 'header:X -Complaints-To:1': 0.28; 'performing': 0.30; 'function': 0.30; 'url:home': 0.33; 'to:addr:python-list': 0.33; 'changed': 0.34; 'false': 0.35; 'subject:?': 0.35; 'add': 0.36; 'received:org': 0.36; "i'll": 0.36; 'test': 0.36; 'charset:us-ascii': 0.36; 'busy': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'end': 0.40; 'within': 0.64; '2013': 0.84; 'subject:anything': 0.84; 'dennis': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: Detecting a click on the turtle screen when the turtle isn't doing anything?
Date Tue, 05 Feb 2013 16:54:22 -0500
Organization > Bestiaria Support Staff <
References <5id7u9x7rd.ln2@news.ducksburg.com> <e348u9x18o.ln2@news.ducksburg.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host adsl-76-249-22-149.dsl.klmzmi.sbcglobal.net
X-Newsreader Forte Agent 3.3/32.846
X-No-Archive YES
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1389.1360101284.2939.python-list@python.org> (permalink)
Lines 51
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1360101284 news.xs4all.nl 6886 [2001:888:2000:d::a6]:43733
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:38233

Show key headers only | View raw


On Tue, 05 Feb 2013 19:45:18 +0000, Adam Funk <a24061@ducksburg.com>
declaimed the following in gmane.comp.python.general:

> >
> > #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
> >

	I'll echo the "Ugh" about the use of global AND ADD a dislike of the
busy loop that only exits if some other return sets a value. If the busy
loop were performing some action that changed the test state within the
loop itself, okay...

-=-=-=-
import threading

evtFlag = threading.Event()

def clicked(x, y):
	print("clicked at %f %f" % (x, y))
	evtFlag.set()
	#don't need "global" as not binding to the name evtFlag
	#don't need "return" as falling off the end of the function
	#	implements return

def wait_for_clicks(s):
	evtFlag.clear()
	s.listen()
	evtFlag.wait()
	#don't need "global" or "return"
	#don't need busy loop; .wait() blocks until some other thread
	#	(GUI callback) sets the Event

-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

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