Python Tkinter question
Fredrik Lundh
fredrik at pythonware.com
Sun Jun 8 17:34:52 EDT 2003
"Thyme" <TDSherer at go.com> wrote:
> I've hit a bump learning to use Tkinter. Nothing I've found on line
> has helped me nail down the problem. Any insights would be welcome.
>
> This is something very easy, actually - I'm trying to use the feature
> a label is assigned a variable so that it can be automatically
> updated. I followed the syntax I found in a Tkinter PDF on line and
> another online doc I found.
>
> Here is some code:
>
> # File: testx.py
> from Tkinter import *
>
> con1 = StringVar("Quick Question!")
>>> import Tkinter
>>> help(Tkinter.StringVar)
Help on class StringVar in module Tkinter:
class StringVar(Variable)
| Value holder for strings variables.
|
| Methods defined here:
|
| __init__(self, master=None)
| Construct a string variable.
|
| MASTER can be given as master widget.
|
| get(self)
| Return value of variable as string.
|
| ----------------------------------------------------------------------
| Methods inherited from Variable:
|
| __del__(self)
| Unset the variable in Tcl.
|
| __str__(self)
| Return the name of the variable in Tcl.
|
| set(self, value)
| Set the variable to VALUE.
in other words, the StringVar constructor takes an optional master (parent)
widget argument, and you must use the "set" method to change the value:
con1 = StringVar()
con1.set("Quick Question!")
</F>
More information about the Python-list
mailing list