[Tutor] after(), how do I use it?

Adam Bark adam.jtm30 at gmail.com
Tue Apr 26 02:50:16 CEST 2011


On 26/04/11 01:36, michael scott wrote:
> Hello, I asked for help in another location and it solved my problem, 
> but the only problem is I don't fully understand the after function. 
> Here is part of the code that was given to me.
>
>
>     def print_label_slowly(self, message):
>         '''Print a label one character at a time using the event loop'''
>         t = self.label.cget("text")
>         t += message[0]
>         self.label.config(text=t)
>         if len(message) > 1:
>             self.after(500, self.print_label_slowly, message[1:])
>
> I understand it, and the gist of how it works, but the self.after... I 
> can not find any documentation on it (because after is such a common 
> word), so can you guys tell me how it works. Is this a built in 
> function (didn't see it on the built in function list)? Does it always 
> take 3 arguements? Is this a user made function and I'm just 
> overlooking where it was defined at?

The function you have shown there appears to be a class method. 
self.after means you are calling another method of the same function 
that print_label_slowly is a part of.
Do you have the rest of the code? If you're still confused post it and 
hopefully we can clear it up for you.

HTH,
Adam.


More information about the Tutor mailing list