[Tutor] help with tkinter?

Michael P. Reilly arcege@shore.net
Wed, 21 Mar 2001 12:42:37 -0500 (EST)


> On Wed, 21 Mar 2001, doc pepin wrote:
> 
> > i've made a timer program with python and tkinter but
> > the problem is i don't know how to display the result
> > or output on the main window and not on the console.
> 
> Hmmm... I believe you should be able to use the Label widget with a
> StringVar, which will let you change the Label's contents on the fly.  For
> example:
[snipped]
> However, there might be a better way of doing this; I haven't gotten past
> StringVars yet.

You can also change the text field manually.

>>> from Tkinter import *
>>> l = Label(None, text='Hi there')
>>> l.pack()
>>> # there should be a flat widget with "Hi there" now
...
>>> l['text'] = 'Whassup'
>>> # and now the text has changed
...
>>> l.config(text='Goodbye')

About the only time you need the Variable classes is when you want to
share values across widgets (mostly the Radiobutton widget).

  -Arcege

-- 
------------------------------------------------------------------------
| Michael P. Reilly, Release Manager  | Email: arcege@shore.net        |
| Salem, Mass. USA  01970             |                                |
------------------------------------------------------------------------