Skip to content Skip to sidebar Skip to footer

Why Can't I Set My Intvar?

I am importing a file that defines a class. The class has wigits that use an IntVar(). Why can't I set the IntVar? class Config: def __init__(self, vector): d = 200

Solution 1:

StringVar, IntVar, DoubleVar, and BooleanVar are Tkinter classes having their own methods. So print size means you are printing the reference to size variable. If you want to display its value you rather need to use the get() method.

Demo:

>>>from Tkinter import *>>>d = 200>>>root = Tk()>>>print d
200
>>>size = IntVar()>>>size.set(d)>>>print size.get()
200
>>>

Post a Comment for "Why Can't I Set My Intvar?"