ANN: Thinking in Tkinter

Greg Ewing see_reply_address at something.invalid
Mon Sep 9 00:18:23 EDT 2002


Stephen Ferg wrote:

> "Joseph A. Knapka" <jknapka at earthlink.net> wrote in message news:<3D798461.B3FE0E06 at earthlink.net>...

 >

>>Also, you should be aware of the "command" option
>
> I know about it, but I think that for beginners, it is very confusing.
< ...  So I think that
> beginners should consistently use the more plodding technique of
> explicit binding.


I hope you're aware that what you're doing in your buttons
example is NOT equivalent to using the "command" option.
The latter does a number of extra things: it waits until
the mouse is released, and triggers the handler only if
the release is within the button.

So if you insist on presenting things the way you are, you'd
better include a clear warning that you're taking a big
short-cut and that you'll explain how to do it correctly
later, otherwise you'll lead people into a very bad habit.

But I wonder whether this isn't going to be more confusing
than just showing the use of the command option from the
beginning.

 >  For one thing, it leads down the path to lambda,

Not if you present your examples using one of the several
reasonable alternatives to lambda which exist.

 > For another, it doesn't automatically pass an event
 > object, which makes it even more difficult to use.

In the case of buttons, this isn't usually a problem,
since all you want to know is that the button was clicked.

-- 
Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg




More information about the Python-list mailing list