tkinter questions: behavior of StringVar, etc

Alan G Isaac alan.isaac at
Sun Mar 29 17:39:51 CEST 2009

On 3/29/2009 7:29 AM Francesco Bochicchio apparently wrote:
> 1. Tkinter is only a thin wrapper over Tk, a GUI library initially 
> developed for Tcl language, so many of the answer to the design choices 
> you question (e.g. what is the master) cannot between answered within 
> the python documentation but should be searched in the Tcl/Tk 
> documentation. So google for tcl/tk. 
> Anyway, all GUI libraries I know of build the GUI as a hierarchical 
> structure. The master (often called root) ia the root of this 
> hierarchy, and you have to build it before building the rest. 

I understand this.  But I do not understand what we get
by having each Variable instance register a master.
(In contrast, e.g., to a container widget, such as a Frame,
where I do not have this question.)

> 2. Another good source of information is the source of Tkinter itself, 
> which is mostly in the file. 

In Python 3, I'm finding most of the useful stuff to be in
``tkinter/``.  It is indeed useful, but not
always transparent.  At least to a new user.

> if you for instance look at the __init__ method of the 
> Variable class (which is the basic class of StringVar), 
> you will easily find the 'magic' to which you refer to.  

What we find is that Variable is initialized with:
         if not master:
             master = _default_root
which in turn is initialized to None.  I understand this.
Actually, talking this through, I get it now.  I was not
properly thinking about the use of module level globals.

> If you don't like the choices which have been made there 
> (e.g not automagically creatinga a master for variables 
> but doing it for frames ), you could try and submit 
> a  patch :-)

I am not so presumptuous.  I just want to understand why a
Variable needs a master.  How is this used?

And, I would like to understand if there is a *reason* that
a StringVar instance, for example, does not behave more like
a string.

> 3. Usually the changes between one version of python and the next are 
> documented (but not in all gory details) in "What is new" documents you 
> can find  in site. I'm not aware of any change 
> for Tkinter, in Python 3.0 but go read it yourself.

I did look there, and explicitly got only that the new name
is ``tkinter``.   However, there are other changes, e.g. the
names and location of ``colorchooser`` and ``filedialog``.
I realize now that the statement "related modules have been
grouped into packages, and usually the submodule names have
been simplified" is supposed to capture all this, but an
explicit list would have been helpful to me.  (And,
I assume, to others.)  I also just assumed that some active
user had made a list of changes, which I had overlooked, but
that someone on this list would be aware of.

Alan Isaac

More information about the Python-list mailing list