Odd behavior in Python/Tkinter?

Fredrik Lundh fredrik at pythonware.com
Fri Dec 21 16:05:34 EST 2007


Lie wrote:

> Inspect the following code:
> 
> --- start of code ---
> import Tkinter as Tk
> from Tkconstants import *
> 
> root = Tk.Tk()
> 
> e1 = Tk.Entry(root, text = 'Hello World')
> e2 = Tk.Entry(root, text = 'Hello World')

the "text" (or "textvariable") option to the Entry widget is the name of 
the Tcl variable that should hold the result.

to get something that's a bit more usable from Python, use a StringVar 
instance instead.  alternatively, use the "get" method to fetch text 
from the widget, and the "insert" method to add text to it.

also see:

     http://effbot.org/tag/Tkinter.entry

</F>




More information about the Python-list mailing list