tkinter questions: behavior of StringVar, etc

Alan G Isaac alan.isaac at gmail.com
Sat Mar 28 19:59:59 EDT 2009


> On Mar 28, 2:15 pm, Alan G Isaac <alan.is... at gmail.com> 
> wrote:
>> I'm a complete newbie to GUI. 
>> I have a couple questions about tkinter. 

>> 1. Where is the list of changes 
>>     in Python 3's tkinter?

>> 2. What exactly is the role of the root object, 
>>     traditionally created as ``root=tk.Tk()``?
>>     What is an example where one should create this
>>     before creating a Frame instance (which will
>>     otherwise implicitly create one as its master)?

>> 2'. Suppose I ``import tkinter as tk`` and 
>>     then try ``s1=tk.StringVar()``.  This fails
>>     because no "master" is set. Why does a
>>     Variable need a master?

>> 3. Now suppose I set ``root = tk.TK()`` and 
>>     then try ``s1=tk.StringVar()``.  This
>>     works fine but now seems a bit magical:
>>     how has the value of the "master" been
>>     set?

>> 4. Another bit of magic:
>>     Suppose I ``import tkinter as tk`` and
>>     then try ``f1=tk.Frame()``.  This works
>>     fine: apparently calling Frame also
>>     leads to implicit creation of a "master".
>>     Why is what is good for the gander (i.e.,
>>     implicit master creation for a Frame) not
>>     good for the goose (i.e., a Variable)?
>>     (Here I assume that there has been an
>>     answer to 2. above.)

>> 5. Reading around a bit, 
>>     it seems common to recommend setting
>>     the values of Variables rather than initializing
>>     them.  Why?  I cannot see the reason to avoid
>>     ``s1=tk.StringVar(value="this works fine")``
>>     and it looks like ``tk.StringVar(()`` is in any
>>     case initialized (to an empty string).

>> 6. Why is str(s1) not its value?  More generally, 
>>     why does a StringVar not behave more like a string?



On 3/28/2009 6:19 PM Mike Driscoll apparently wrote:
> Try Google and the Python website. There is tons of info on the Python 
> wiki:
> http://wiki.python.org/moin/TkInter 
> There are also some books that walk you through Tkinter application 
> creation, for example,Lutz's "Programming Python". 


Sorry, but I do not see the answers to any of the above
questions, not even the first one.  Do you?  (One might
believe question 2 is answered, but if you read it, I
think you will see why I do not.)

Cheers,
Alan Isaac



More information about the Python-list mailing list