passing arguments from scale widget to function

Matt Hammond matt.hammond at
Mon Aug 22 13:31:31 CEST 2005

On Mon, 22 Aug 2005 12:16:01 +0100, m7b52000 <tpearce at>  

>>     command = lambda : Calc(a.get())

> I get the following message when I use lambda as above:
> TypeError: <lambda>() takes no arguments (1 given)

Oops, forgot! The Scale widget outputs a single argument - the value of  
the slider. You therefore could write:

    command = lambda value : Calc(value)

or even simpler:

    command = Calc

In the latter case, you're supplying your "calc" function as the function  
to be called. Calc takes a single argument - the value of the slider, so  
it fulfills the task. Note that we're passing "Calc" (the function  
itself), not "Calc(...)" (the result of calling the function)




| Matt Hammond
| R&D Engineer, BBC Research and Development, Tadworth, Surrey, UK.

More information about the Python-list mailing list