[Tkinter-discuss] Finding variable associated with checkbutton
Guilherme Polo
ggpolo at gmail.com
Thu Jul 9 15:53:37 CEST 2009
On Wed, Jul 8, 2009 at 6:05 PM, Cameron Laird<Cameron at phaseit.net> wrote:
> On Wed, Jul 08, 2009 at 01:37:52PM -0700, VladPotrosky wrote:
> .
> .
> .
>> How do you find the variable which a checkbutton is linked to?
>> example:
>>
>>
>> v = IntVar()
>> c = Checkbutton(master, text='Foo', variable=v)
>>
>> how do you then find out (with code) that v is linked to c?
> .
> .
> .
> if v._name == c.cget("variable").string:
> print "Ah-ha! They *do* match."
>
> Maybe there is a better way. That's as far as I've thought about it.
I would opt to do the check str(v) == str(c['variable']) instead, less
intrusive.
--
-- Guilherme H. Polo Goncalves
More information about the Tkinter-discuss
mailing list