Changing global variables in tkinter/pmw callback

Brian Elmegaard be at mek.dtu.dk
Fri Apr 6 06:13:19 EDT 2001


Alex Martelli wrote:
> 

> 
> You never HAVE to use a lambda: it's supposed to be a convenience,
> but, whenever you can use a lambda, you can just as well use a
> (named) local function object if that seems clearer to you (and
> often it WILL be clearer to most readers).

I never found out how to pass arguments to a tkinter callback without
using a lambda.

How would this look without the lambda:
button.configure(command = lambda self=self,
                 button=button, buttons=self.buttons,
                 setting=CurrentCanvasSetting:
                 self.apply(button,buttons,setting))


In apply I do:
         def apply(self,button,buttons,setting):
             setting[0]= button.cget('text')


> argument N... then 3 now had a value of four!!!  If some place

Well, I can't that I would like to have that in python. 

> completely immutable objects -- programming becomes a funny
> game indeed if the actual values of numbers start changing
> from under our feet.

It could be rather challenging.

> So, Python hits a pragmatical compromise: some of the key

And that's what I really like about python, it's the pragmatical
compromise.

> it turns out that just about ALL references in Python are

OK. How could global rebinding be done to my original setting from
apply?

-- 
Brian
http://www.et.dtu.dk/energysystems
http://www.rk-speed.dk http://fiduso.dk http://sunsite.auc.dk/dk-tug
\TeX, tak



More information about the Python-list mailing list