[Tutor] Misunderstanding the Entry Widget

Kent Johnson kent37 at tds.net
Fri Mar 6 14:00:34 CET 2009


On Fri, Mar 6, 2009 at 7:15 AM, Wayne Watson
<sierra_mtnview at sbcglobal.net> wrote:
> Control variables. What is the difference between IntVar,  BooleanVar,
> StringVar,  and DoubleVar?

The difference is the type of value returned by get().

>  For example, in the program below, it looks like
> I get the same result usint IntVar or StringVar. It almost appears the usage
> depends on what widget one uses: Entry, RadioButton, CheckBox, ...
>
> ===================begin=========
> from Tkinter import *
> # Use of control variables
>
> def mycallback():
>     print "User entered:" , e.get()
>     print "Operationg by 2 gives: ", e.get()*2

Change the above to use v.get(). e.get() has nothing to do with the var.

> master = Tk()
>
> v=StringVar()
> #v=IntVar()
> print v,type(v)

Try this:
print v, type(v), type(v.get())

Kent


More information about the Tutor mailing list