tkinter event object question

Arun Ramanathan aramanat at optonline.net
Thu Jul 5 21:34:44 EDT 2001


Is there a way by which I can determine which tkinter widget
actually generated the event.

Example if I had two buttons b1 and b2 initialized as shown below
and bound to the event handler callme.

-------------------------------
from Tkinter import *

root = Tk()

def callme(event)
    print "santa is coming"    # is there a way I can find out which
button
                                         # generated the event in the
event handler?

b1 = Button(root,text='b1')
b1.bind("<Button-1>",callme)
b1.pack()

b2= Button(root,text='b2')
b2.bind("<Button-1>",callme)
b2.pack()

root.mainloop()
------------------------------



Thanks,

Arun




More information about the Python-list mailing list