[Q] Binding a Button

Siew-Ann Cheong cheong at msc.cornell.edu
Fri May 31 14:24:22 EDT 2002


Hi,

I have a button widget packed into a frame that contains several buttons.
In the constructor, I specified the button to be bound to a callback
function that pops a child dialog window.

I notice that when I hit the <Tab> key, the buttons packed in the
frame are sequentially highlighted, so I presumed that the natural
behaviour would be for the <Enter> key to also invoke the callback
function associated with the highlighted button.  I did that and nothing
happened, and so I decided to bind the <Enter> key by hand using the
widget.bind() method.

However, I immediately encounter a problem: the callback function to pop
the child dialog window takes two arguments --- self and master --- and so
when I try to bind the <Enter> key to this function, python complains that
the callback function expects two arguments but got only one.  Alternatively,
binding with

	button.bind("<Enter>", callback(button) )

does not produce the correct behaviour.

Would anyone be kind enough to show me how the expected behaviour, i.e.
highlighted button invokes the callback function bound to it?  Or if this is
an FAQ, can anyone point me to the appropriate place so that I can read
it myself?

Thanks in advance?


Cheong Siew Ann



More information about the Python-list mailing list