ANN: Thinking in Tkinter
see_reply_address at something.invalid
Wed Sep 11 22:30:27 EDT 2002
Stephen Ferg wrote:
> So it looks like the
> correct mouse-button binding to replace "command" would be to bind to
That's not quite right either, because the action
should only be triggered if the mouse is released
inside the button.
> Is there any place where definitions or explanations
> or discussions of standard button behavior are written down
> and available? A book? A Web page?
Apple publishes a Human Interface Guidelines document,
which ought to be on their website somewhere. There's
probably something similar from Microsoft.
The generally accepted behaviour for a button on
most platforms nowadays is:
(1) Mouse-down in the button causes it to be highlighted
in some way (changing colour, becoming "depressed", etc.)
(2) As long as the mouse is held down, the button is
unhighlighted when the mouse moves out of it, and
re-highlighted when it moves back in.
(3) If the mouse is released inside the button, the
button's action is performed. If the mouse is
releases outside the button, nothing happens.
There's no single event binding in Tk that will give
you all of this. There is code built into the Button
widget that implements it, but to take advantage of
it you have to use the "command" option.
It's a fairly universal principle in Tk that the
"command" of a widget is invoked according to the
standard behaviour of that widget, so I think it
deserves treatment as a fundamental principle
on the same footing as event binding.
Greg Ewing, Computer Science Dept,
University of Canterbury,
Christchurch, New Zealand
More information about the Python-list