What is intvar?

Chris Rebert clp2 at rebertia.com
Thu Jan 22 21:45:26 EST 2009


On Thu, Jan 22, 2009 at 6:38 PM, W. eWatson <notvalid2 at sbcglobal.net> wrote:
> I'm looking at someone's code in which invar() is used fairly often.
> Apparently, it's a Tkinter method. Here's a use:
>    def body(self,master):
>        self.title("Display Settings")
>
>        self.colorVar = IntVar()
>        Radiobutton( master, text="Gray Scale",
>                     value=1, variable=self.colorVar).grid(row=0, sticky=W)
>        Radiobutton( master, text="Pseudo Color",
>                     value=2, variable=self.colorVar).grid(row=1, sticky=W)
>        ...
>
> What is the need for this use? It looks like some sort of initialization for
> a widget.
>
> I've scoured the internet with Google, and have yet to find a simple
> explanation of what it's used for.

Search for IntVar on http://docs.python.org/library/tkinter.html and
read the enclosing section.
I think it's basically used to propagate changes to the GUI and
convert values (in this case, ints) between Python and Tk.

Cheers,
Chris

-- 
Follow the path of the Iguana...
http://rebertia.com



More information about the Python-list mailing list