Python Tkinter question

Thyme TDSherer at go.com
Mon Jun 9 04:53:29 CEST 2003


Thank you!

The final problem was that it had to be declared global or it would go
out of scope before I could use it.

For a few minutes there, I almost said, Bag this - I'm going back to
Java!

Tim


"Fredrik Lundh" <fredrik at pythonware.com> wrote in message news:<mailman.1055108236.26677.python-list at python.org>...
> "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