I've just got to stop using one letter for variables, especially ones that sound alike! :-)

Other than v tracking every value change made, did I gain anything by using it? It seems to me that control variables are of marginal use. I might have thought they were necessary for use with scale widgets, but I'm looking at an example that says otherwise. Can you easily construct a simple example where they are absolutely necessary, or at least provide a situation where they are necessary?

Kent Johnson wrote:
On Fri, Mar 6, 2009 at 7:15 AM, Wayne Watson
<sierra_mtnv...@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

  

--
Signature.html
           Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

             (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)
            

                In mathematics you don't understand things. 
                 You just get used to them. -- John Von Neumann
                    (P.S. The same is true in life.)

                    Web Page: <www.speckledwithstars.net/>
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to