[Tkinter] Entry widget and textvariable option?
Bob van der Poel
bvdpoel at uniserve.com
Fri Jun 30 16:50:55 EDT 2000
Jerome Quelin wrote:
>
> Hi all,
>
> I can't manage to use the textvariable option in an Entry widget. And
> I can't find docs on this... And since we can't take references to
> variables in Python, I don't see how to use this feature?
>
> When running the following code:
>
> >>> from Tkinter import *
> >>> Entry(width=10, textvariable=spam).pack()
>
> spam is to be defined, since Python interpolates it in the previous
> statement. And that is definitely _not_ what I want Python to do! I
> want the content of the Entry to go into the variable spam... In perl,
> I would use '\$spam' to take a reference to the variable, and in Tcl
> I'd use 'spam' to indicate a variable name, without interpolating
> it. But what should I do in Python? 'spam' interpolates the content of
> the spam variable, and we can't take variable references in Python...
> Is it that we can't use the textvariable option in Python/Tkinter?
>
> Any help welcome.
>
> Thanks,
> Jerome
> --
> jerome.quelin at insalien.org
This should be put into a FAQ...
The variable has to be a Tk type. So, do something like:
spam=StringVar()
and update with
spam.set("Monty")
--
__
/ ) / Bob van der Poel
/--< ____/__ bvdpoel at uniserve.com
/___/_(_) /_) http://users.uniserve.com/~bvdpoel
More information about the Python-list
mailing list