Getting the sender widget's name in function (Tkinter)
Harlin Seritt
harlinseritt at yahoo.com
Tue Apr 26 15:59:25 EDT 2005
I have the following script. Two widgets call the same function. How
can I tell inside of the called function which button called it?:
def say_hello():
print 'hello!'
print widget['text']
root = Tk()
button1 = Button(root, text='Button 1', command=say_hello)
button1.pack()
button2 = Button(root, text='Button 2', command=say_hello)
button2.pack()
root.mainloop()
Thanks,
Harlin Seritt
More information about the Python-list
mailing list