passing arguments from scale widget to function

Matt Hammond matt.hammond at rd.bbc.co.uk
Mon Aug 22 04:19:12 EDT 2005


On Sun, 21 Aug 2005 08:09:55 +0100, m7b52000 <oh_no_you_don't at noSPAM.com>  
wrote:

> It is proving most difficult in Python. How do I pass the .get() values  
> to my calculating function? Do I use the command option for each slider?  
> e.g command = Calc(a.get()). Obviously not cos it doesn't work.

It should work if you wrap it as a lambda function. As it is, you're  
assigning the
result of the Calc() function to the 'command' argument/parameter of the  
slider widget. What you actually want is to assign just the function:

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

> I am not a real programmer and do not wish to get involved in classes  
> and objects....

If you're using Tcl/Tk you're already using them ... what do you think  
your Slider widget is? :-)

Hope this helps!

regards


Matt
-- 

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



More information about the Python-list mailing list