[Tutor] Now where do I go from here in this program??????

Michael P. Reilly arcege@shore.net
Wed, 7 Mar 2001 15:41:07 -0500 (EST)


> I want to repeat/refresh App so I get a continually running clock.  Instead 
> of one instance.  This program so far works good but it only gives one 
> instance in time.

First, put the time setting functionality into a method, then
using the widget's after() method, have that method called every second.

class Spam(Label):
  images = ['bite00.xpm', 'bite01.xpm', 'bite02.xpm', 'bite00.xpm']
  def __init__(self, master):
    self.imageno = 0
    Label.__init__(self, master)
    self.take_a_bite()
    self.start_biting()
  def take_a_bite(self, event=None):
    self.config(bitmap=self.images[self.imageno])
    # go the next image next time
    self.imageno = (self.imageno + 1) % len(self.images)

  def start_biting(self):
    self.after_id = self.after(1000, self.take_a_bite)
  def stop_biting_me(self):
    self.after_cancel(self.after_id)
Spam(None).pack()

You'd need images to for this example, but the principle should work
the same for changing another label' text.

  -Arcege

-- 
------------------------------------------------------------------------
| Michael P. Reilly, Release Manager  | Email: arcege@shore.net        |
| Salem, Mass. USA  01970             |                                |
------------------------------------------------------------------------