tkinter call backs
Dan Pettersson
dan.pettersson at its.uu.se
Thu Jul 22 05:29:07 EDT 1999
Timothy R Evans wrote:
> class Command:
> def __init__(self, func, *args, **kw):
> ...
> apply(self.func, args, kw)
>
> Used as following:
>
> Button(text='foo', command=Command(myfunction, myarg))
>
> The args (including keywords) that are passed to the Command class are
> passed on to myfunction when the callback is activated.
>
> I'm wondering if this should be part of Tkinter in some way?
You can get the same behaviour by using a lambda and defaults
Button(text='foo', command=lambda e,x=arg1, y=arg2 : function(e,x,y))
Apologies if all arguments aren't in the write place my TkInter is a bit
rusty.
--
Dan Pettersson IT Support, Uppsala University, SWEDEN
More information about the Python-list
mailing list