[Tkinter-discuss] What is wrong with this?

Mannequin* mannslists at invigorated.org
Sun Jan 21 18:43:28 CET 2007


Cameron Laird wrote:
> On Sun, Jan 21, 2007 at 04:59:29PM +0000, Mannequin* wrote:
> 			.
> 			.
> 			.
>> the tests I've done. I was reading a book that said I could do it, but 
>> it's a bit old (for Python 2.1). I only really use it for a reference.
> 			.
> 			.
> 			.
> ?!
> 
> You've got me curious.  These Tkinter command semantics 
> haven't changed for at least a decade; it's not a question
> of version skew.  I'm not aware of any book which confuses
> functions with their evaluations as you describe; which is
> it?
> 
> Maybe we can help you obtain better references.

It is the "Python 2.1 Bible", by Dave Brueck and Stephen Tanner, 
published by Hungry Minds Inc. They have a script on page 352 - 353 that 
pretty much has the example where I gleaned that you could what I tried 
to do.

What confuses me is that in the comments before these two sections 
below, the author wrote in reference to the Button["command"] method 
(which applies to the other methods of defining an action for a widget) 
that you couldn't pass an argument: "Button["command"] is the function 
to execute (without arguments)..." But clearly in the example that I've 
copied below, the author uses arguments!

-------------------------------------------------------------------------------------

# For reference, SpamButton is a button created previously in this script.
# ...

SpamButton["command"]=self.BuildButtonAction("Spam")

# ...

Tkinter.Button(ButtonFrame,text="Beans",\
	command=self.BuildButtonAction("Beans")).pack(side=Tkinter.LEFT)

# ...

-------------------------------------------------------------------------------------

I do have other references, Python's home page and "Programming Python", 
by Mark Lutz, published by O'Reilly, for instance. But the "Python 2.1 
Bible" is written that it is easier for a quick reference. (Yes, I 
somehow thing a properly arranged book is still quicker than the 
internet. :) )

-M.


More information about the Tkinter-discuss mailing list