Changing global variables in tkinter/pmw callback

Brian Elmegaard be at mek.dtu.dk
Thu Apr 5 06:53:38 EDT 2001


Thanks a lot, Fredrik.

I now learned how to do it.

I use a list instead of a "variable" for the CurrentCanvasSetting. This
allows me to use it as a global variable, and I can get the wanted
behavior. 
Still, I don't really understand the reasons. I have tried to look in
the tutorial, the lib-ref and the lang-ref. However, for a
non-CS-engineer it's too hard to get a meaningful explanation. Can it be
written in a few words, so I may understand why lists are (and have to
be) so different from "normal" variables?

Fredrik Lundh wrote:
> 
> has nothing to do with scopes -- objects and assignments don't work
> as you and your code expects.

Don't blame the code.

> 
> I'll leave it to alex to write the long, pedagogical explanation.

Looking forward to it.

-- 
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