Odd behavior in Python/Tkinter?

Lie Lie.1296 at gmail.com
Fri Dec 21 17:02:06 EST 2007


On Dec 22, 4:05 am, Fredrik Lundh <fred... at pythonware.com> wrote:
> 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>

I realized that 'text' isn't a normally valid arguments for Entry (and
I'm also aware about the insert, get, etc), but what makes me creep is
the fact that the Entry's value would mirror each other if they're set
to the same 'text' value (Actually, I'm interested on how they
implement the Tkinter's/Tcl/Tk Entry box that this kind of behavior
could ever possibly exist [I started Pythoning just two weeks ago, so
my knowledge on its internals is quite limited]).



More information about the Python-list mailing list