A
Alan G Isaac
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?
Thanks for any insights,
Alan Isaac
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?
Thanks for any insights,
Alan Isaac