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


Groups > comp.lang.python > #77336

Re: Sequencing images using tkinter?

From Peter Otten <__peter__@web.de>
Subject Re: Sequencing images using tkinter?
Date 2014-08-30 23:14 +0200
Organization None
References <dcff98af-47cd-4dbc-9fa1-02dc6813df81@googlegroups.com> <7eedecff-7ff3-43f5-ae47-7283f115cad2@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.13654.1409433267.18130.python-list@python.org> (permalink)

Show all headers | View raw


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)
              


Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Sequencing images using tkinter? theteacher.info@gmail.com - 2014-08-30 08:54 -0700
  Re: Sequencing images using tkinter? Terry Reedy <tjreedy@udel.edu> - 2014-08-30 15:52 -0400
  Re: Sequencing images using tkinter? Peter Otten <__peter__@web.de> - 2014-08-30 21:54 +0200
  Re: Sequencing images using tkinter? theteacher.info@gmail.com - 2014-08-30 13:11 -0700
  Re: Sequencing images using tkinter? theteacher.info@gmail.com - 2014-08-30 13:27 -0700
    Re: Sequencing images using tkinter? "Albert Visser" <albert.visser@gmail.com> - 2014-08-30 22:49 +0200
  Re: Sequencing images using tkinter? theteacher.info@gmail.com - 2014-08-30 13:37 -0700
    Re: Sequencing images using tkinter? Peter Otten <__peter__@web.de> - 2014-08-30 23:14 +0200
      Re: Sequencing images using tkinter? theteacher.info@gmail.com - 2014-08-31 02:51 -0700

csiph-web