[Tutor] Timer?
Daniel Yoo
dyoo@hkn.eecs.berkeley.edu
Sat, 31 Mar 2001 19:37:05 -0800 (PST)
On Sat, 31 Mar 2001, VanL wrote:
> >
> > ###
> > from Tkinter import *
> >
> > class BlinkingButton(Button):
> > def __init__(self, master, **kwargs):
> > Button.__init__(self, master, **kwargs)
> > self.blinkerson = 1
> > self.blink()
> >
> > def blink(self):
> > if self.blinkerson:
> > self.flash()
> > self.after(1000, self.blink)
> >
> > if __name__ == '__main__':
> > root = Tk()
> > BlinkingButton(root, text="Blinking Button!").pack()
> > mainloop()
> > ###
>
> I was testing out what you said and this code didn't work for me. It created a
> button, but it didn't blink.
> Do you know why?
Hmm... the code is Python 2.0 specific, since I'm doing the call:
Button.__init__(self, master, **kwargs)
If this is what's causing problems, then let's replace it with something
more compatible:
apply(Button.__init__, [self, master], kwargs)
They both do the same thing: they call the Button.__init__ function while
giving the user lots of freedom to specify keyword arguments. However,
I've only been able to test this on my Linux computer; has anyone else had
success with this?