Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

What is intvar?

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


notvalid2 at sbcglobal

Jan 22, 2009, 6:38 PM

Post #1 of 9 (5933 views)
Permalink
What is intvar?

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.
--
W. eWatson

(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
Obz Site: 39 15' 7" N, 121 2' 32" W, 2700 feet

Web Page: <www.speckledwithstars.net/>

--
http://mail.python.org/mailman/listinfo/python-list


clp2 at rebertia

Jan 22, 2009, 6:45 PM

Post #2 of 9 (5856 views)
Permalink
Re: What is intvar? [In reply to]

On Thu, Jan 22, 2009 at 6:38 PM, W. eWatson <notvalid2 [at] sbcglobal> 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
--
http://mail.python.org/mailman/listinfo/python-list


rhodri at wildebst

Jan 22, 2009, 7:00 PM

Post #3 of 9 (5855 views)
Permalink
Re: What is intvar? [In reply to]

On Fri, 23 Jan 2009 02:38:32 -0000, W. eWatson <notvalid2 [at] sbcglobal>
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.

Chris has already pointed you to the Tkinter documentation, which is a
good start but a little less than clear in places.

What your example code does is to associate self.colorVar with the set
of radio buttons. This isn't just initialisation, it's a full reflection
of the current state.

self.colorVar.get() returns the "value" parameter that you gave to the
radio button which is currently selected (so, for example, if it returns
1 you know that the "Grey Scale" button is the one selected). Similarly
self.colorVar.set(n) selects whichever radio button has the "value" which
matches n (so self.colorVar.set(2) selects the "Pseudo Color" button).

IntVar and StringVar (and DoubleVar if you must :-) are basically the
easy way of dynamically reading and changing the values in various
entry widgets, the text on buttons, and so on.

--
Rhodri James *-* Wildebeeste Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list


rt8396 at gmail

Jan 22, 2009, 7:19 PM

Post #4 of 9 (5859 views)
Permalink
Re: What is intvar? [In reply to]

here is a good explanation of control vars:
http://infohost.nmt.edu/tcc/help/pubs/tkinter/control-variables.html

Here are 3 great Tkinter refernces in order:
http://infohost.nmt.edu/tcc/help/pubs/tkinter/
http://effbot.org/tkinterbook/
http://www.pythonware.com/library/tkinter/introduction/
--
http://mail.python.org/mailman/listinfo/python-list


notvalid2 at sbcglobal

Jan 23, 2009, 5:56 AM

Post #5 of 9 (5842 views)
Permalink
Re: What is intvar? [In reply to]

r wrote:
> here is a good explanation of control vars:
> http://infohost.nmt.edu/tcc/help/pubs/tkinter/control-variables.html
>
> Here are 3 great Tkinter refernces in order:
> http://infohost.nmt.edu/tcc/help/pubs/tkinter/
> http://effbot.org/tkinterbook/
> http://www.pythonware.com/library/tkinter/introduction/
Thanks to all for the reference and tips.

--
W. eWatson

(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
Obz Site: 39 15' 7" N, 121 2' 32" W, 2700 feet

Web Page: <www.speckledwithstars.net/>

--
http://mail.python.org/mailman/listinfo/python-list


notvalid2 at sbcglobal

Jan 24, 2009, 6:15 AM

Post #6 of 9 (5837 views)
Permalink
Re: What is intvar? [In reply to]

W. eWatson wrote:
> r wrote:
>> here is a good explanation of control vars:
>> http://infohost.nmt.edu/tcc/help/pubs/tkinter/control-variables.html
>>
>> Here are 3 great Tkinter refernces in order:
>> http://infohost.nmt.edu/tcc/help/pubs/tkinter/
>> http://effbot.org/tkinterbook/
>> http://www.pythonware.com/library/tkinter/introduction/
> Thanks to all for the reference and tips.
>
tkinterbook is easy to follow, but it seems to have been abandoned in 2005.
Did it appear in another guise somewhere else?

--
W. eWatson

(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
Obz Site: 39 15' 7" N, 121 2' 32" W, 2700 feet

Web Page: <www.speckledwithstars.net/>

--
http://mail.python.org/mailman/listinfo/python-list


steve at holdenweb

Jan 24, 2009, 10:40 AM

Post #7 of 9 (5842 views)
Permalink
Re: What is intvar? [In reply to]

W. eWatson wrote:
> W. eWatson wrote:
>> r wrote:
>>> here is a good explanation of control vars:
>>> http://infohost.nmt.edu/tcc/help/pubs/tkinter/control-variables.html
>>>
>>> Here are 3 great Tkinter refernces in order:
>>> http://infohost.nmt.edu/tcc/help/pubs/tkinter/
>>> http://effbot.org/tkinterbook/
>>> http://www.pythonware.com/library/tkinter/introduction/
>> Thanks to all for the reference and tips.
>>
> tkinterbook is easy to follow, but it seems to have been abandoned in
> 2005. Did it appear in another guise somewhere else?
>
There hasn't been a lot of development on Tkinter in the intervening
period. It's a mature system, so there has been no need to update the
documentation.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

--
http://mail.python.org/mailman/listinfo/python-list


notvalid2 at sbcglobal

Jan 25, 2009, 4:49 AM

Post #8 of 9 (5838 views)
Permalink
Re: What is intvar? [In reply to]

Steve Holden wrote:
> W. eWatson wrote:
>> W. eWatson wrote:
>>> r wrote:
>>>> here is a good explanation of control vars:
>>>> http://infohost.nmt.edu/tcc/help/pubs/tkinter/control-variables.html
>>>>
>>>> Here are 3 great Tkinter refernces in order:
>>>> http://infohost.nmt.edu/tcc/help/pubs/tkinter/
>>>> http://effbot.org/tkinterbook/
>>>> http://www.pythonware.com/library/tkinter/introduction/
>>> Thanks to all for the reference and tips.
>>>
>> tkinterbook is easy to follow, but it seems to have been abandoned in
>> 2005. Did it appear in another guise somewhere else?
>>
> There hasn't been a lot of development on Tkinter in the intervening
> period. It's a mature system, so there has been no need to update the
> documentation.
>
> regards
> Steve
Unfortunately, the author seems to have stopped mid-stream. I see a fair
number of FIXMEs in it. It looks like the New Mexico pdf is a fitting
replacement. Perhaps Intro to Tkinter should be scrapped?

Another of the author's writings, on PIL, looks good as a pdf, but is
missing a TOC. Maybe some pdf knowledgeable person knows how to generate one
easily.

--
W. eWatson

(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
Obz Site: 39 15' 7" N, 121 2' 32" W, 2700 feet

Web Page: <www.speckledwithstars.net/>

--
http://mail.python.org/mailman/listinfo/python-list


rt8396 at gmail

Jan 25, 2009, 5:27 PM

Post #9 of 9 (5844 views)
Permalink
Re: What is intvar? [In reply to]

W. eWatson,

I contacted the author of New Mexico Techs "Introduction to Tkinter" a
couple of weeks ago. He is going to update the reference material with
a few missing widgets and some info on Photo and Bitmap classes. I
really love the NMT layout and use it quite often. Fredricks
Tkinterbook is more detail but lacking in navigation. I swing back and
forth between both sites.




--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.