Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!zen.net.uk!dedekind.zen.co.uk!news.stack.nl!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'tkinter': 0.07; 'exit': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:using': 0.09; 'def': 0.12; 'function?': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'seconds.': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; 'header:X-Complaints-To:1': 0.27; 'function': 0.29; "doesn't": 0.30; 'invoke': 0.31; 'schedules': 0.31; 'problem': 0.35; 'subject:?': 0.36; 'to:addr:python-list': 0.38; 'itself': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'tell': 0.60; 'times': 0.62; 'email addr:gmail.com': 0.63; 'skip:n 10': 0.64; 'skip:m 50': 0.68; 'limit': 0.70; 'introduce': 0.78; 'indefinitely': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Peter Otten <__peter__@web.de> Subject: Re: Sequencing images using tkinter? Date: Sat, 30 Aug 2014 23:14:10 +0200 Organization: None References: <7eedecff-7ff3-43f5-ae47-7283f115cad2@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Gmane-NNTP-Posting-Host: p57bdad69.dip0.t-ipconnect.de User-Agent: KNode/4.13.3 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1409433267 news.xs4all.nl 2913 [2001:888:2000:d::a6]:48742 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:77336 theteacher.info@gmail.com wrote: > How do you exit from this function? > > def next_image(): > myLabel.config(image=random.choice(monster_images)) > # tell tkinter to invoke next_image() again after 200 miliseconds You misunderstand. The problem with the function is not that it doesn't exit, it's just that with > root.after(200, next_image) it schedules itself to be reinvoked by tkinter after 200 seconds. If you want to limit that to 10 times instead of indefinitely you can introduce a counter: n = 10 def next_image(): global n myLabel.config(image=random.choice(monster_images)) n -= 1 if n > 0: root.after(200, next_image)