tkinter: making multiple command bindings

richard_chamberlain richard_chamberlain at ntlworld.com
Sat Jun 17 10:43:01 EDT 2000


Hi Bob,

from Tkinter import *
root=Tk()
button=Button(root,text='Click Me')
button.pack()
def Hello(event):
    print 'Hello from ',event.widget
def Goodbye(event):
    print 'Goodbye from ',event.widget
button.bind('<Button>',lambda event:(Hello(event),Goodbye(event)))
root.mainloop()

<EOF>

I believe that is what you mean, I probably wouldn't do it that way though.
I'd create a method which calls the others which is a bit more verbose but
more useful I think.

Richard

Bob van der Poel <bvdpoel at uniserve.com> wrote in message
news:394AF971.CCA0C410 at uniserve.com...
>
> In tcl/tk I can bind a sequence of commands to an event-binding:
>
> bind $w.e <Return> {destroyWin $w; func1; func2 $parm}
>
> Is it possible to do the same in tkinter? I'm sure it has to do with the
> use of lambda (learned that last week in creating a function call with
> an arg...thanks!).
>
>
> --
>    __
>   /  )      /         Bob van der Poel
>  /--<  ____/__        bvdpoel at uniserve.com
> /___/_(_) /_)         http://users.uniserve.com/~bvdpoel
>





More information about the Python-list mailing list