[Tkinter-discuss] Re: Storing structured, 'widget-specific-data', then loading it back in la ter

Chris Nethery clnethery at juno.com
Tue Oct 5 07:09:55 CEST 2004


Fredrik,

Sorry for the delay.  Needed to work on this one a bit.  I think you identified, rather quickly, an area I don't really understand.  I have been struggling quite a bit with variable-passing (for starters) and function-calls.

For the first example, I think I'm accessing the widget's position in memory.  I think this is also true of the second example, but I am making the variables accessible to other methods in the class.
For the third example, I believe that 'variable' becomes the function call.  For the fourth and fifth examples, I am calling a function within another function and passing self.widget (as a variable) into the function that is called... ...I think.


Also, I am very confused by:

1) The creation of a local function.  Why do I need to do this?  What are the rules that require one to create a 'sub'-function (nested function?) ?

2) The self=self statement in the my_callback function.  Doesn't the class already know that self=self, and if not, why don't I have to do this every time I pass self to other functions in the class?

3) Lambda.  This may be more of a 'How does Lambda work?' question than anything, but here goes... ...With Button(..., command=lambda: self.getStoredData(self.widget)), am I creating another local function within the Button-widget method-call?  And, why do I need to do this, rather than call a variable assigned to the function call?

Thank you for your help!


--Christopher Nethery


More information about the Tkinter-discuss mailing list