tkinter: making widgets instance or not?

Fredrik Lundh fredrik at pythonware.com
Tue Jun 6 15:25:33 EDT 2006


John Salerno wrote:

> I'm wondering, why is frame created as a local variable, and the buttons 
> as instance variables? What is the difference? Can you make frame an 
> instance variable, or vice versa?

Tkinter maintains its own widget hierarchy, and widgets don't go away 
unless you explicitly destroy them (by calling "destroy" on a widget or 
a widget parent), so you don't really need to keep references to them.

however, if you need to access a widget later on, it might be a good 
idea to save a reference to it somewhere...

</F>




More information about the Python-list mailing list