In article [EMAIL PROTECTED],
Eric Brunel [EMAIL PROTECTED] wrote:
On 26 Apr 2005 13:37:29 -0700, infidel [EMAIL PROTECTED] wrote:
from Tkinter import Tk, Button
def say_hello(event):
print 'hello!'
print event.widget['text']
root = Tk()
button1 = Button(root, text='Button 1')
Cameron Laird wrote:
In article [EMAIL PROTECTED],
Eric Brunel [EMAIL PROTECTED] wrote:
Unfortunately, making a binding to Button-1 on Button widgets does not
have the same behavior as setting their 'command' option.
Without unraveling my own confusion about who has said what to whom, does
Here's a slight variation of tiissa's solution that gives the callable
a reference to the actual widget instead of just it's name:
from Tkinter import Tk, Button
class say_hello:
def __init__(self, widget):
self.widget = widget
def __call__(self):
print 'Hello,',
In article [EMAIL PROTECTED],
tiissa [EMAIL PROTECTED] wrote:
.
.
.
So far, the OP is proposed the choice to either use the event/bind
mecanism or use different callbacks for his different buttons (either
with the method I
Cameron Laird wrote:
In article [EMAIL PROTECTED],
tiissa [EMAIL PROTECTED] wrote:
So far, the OP is proposed the choice to either use the event/bind
mecanism or use different callbacks for his different buttons (either
with the method I proposed or not).
Is there general understanding that use
On 26 Apr 2005 13:37:29 -0700, infidel [EMAIL PROTECTED] wrote:
from Tkinter import Tk, Button
def say_hello(event):
print 'hello!'
print event.widget['text']
root = Tk()
button1 = Button(root, text='Button 1')
button1.bind('Button-1', say_hello)
button1.pack()
button2 = Button(root,
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 =
Harlin Seritt wrote:
I have the following script. Two widgets call the same function. How
can I tell inside of the called function which button called it?:
As far as I know you can't (but I can be proven wrong).
You may try to define a class to solve this (not tested):
class say_hello:
from Tkinter import Tk, Button
def say_hello(event):
print 'hello!'
print event.widget['text']
root = Tk()
button1 = Button(root, text='Button 1')
button1.bind('Button-1', say_hello)
button1.pack()
button2 = Button(root, text='Button 2')
button2.bind('Button-1', say_hello)
button2.pack()