Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #63207

Re: gotta love radio buttons

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'assign': 0.07; 'elements.': 0.07; 'error:': 0.07; 'indices': 0.07; 'indexes': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'buttons,': 0.16; 'integers,': 0.16; 'iteration': 0.16; 'loops': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'skip:3 30': 0.16; 'subject:buttons': 0.16; 'typeerror:': 0.16; 'elements': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'advance.': 0.19; 'later': 0.20; 'header:User-Agent:1': 0.23; 'helper': 0.24; 'received:comcast.net': 0.24; 'values': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; "i'm": 0.30; 'work.': 0.31; 'info.': 0.31; 'file': 0.32; '(most': 0.33; 'but': 0.35; 'var': 0.36; 'so,': 0.37; 'list': 0.37; 'button': 0.38; 'thank': 0.38; 'to:addr:python-list': 0.38; 'issue': 0.38; 'list,': 0.38; 'pm,': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'radio': 0.60; 'then,': 0.60; 'first': 0.61; 'email addr:gmail.com': 0.63; '26,': 0.68; 'want:': 0.84; '1:18': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Ned Batchelder <ned@nedbatchelder.com>
Subject Re: gotta love radio buttons
Date Sun, 05 Jan 2014 13:37:25 -0500
References <8dca57e8-8258-4020-9788-987af332b5b2@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host c-50-133-228-126.hsd1.ma.comcast.net
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.2.0
In-Reply-To <8dca57e8-8258-4020-9788-987af332b5b2@googlegroups.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4955.1388947062.18130.python-list@python.org> (permalink)
Lines 33
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1388947062 news.xs4all.nl 2946 [2001:888:2000:d::a6]:39690
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:63207

Show key headers only | View raw


On 1/5/14 1:18 PM, eneskristo@gmail.com wrote:
> So, I'm having this radio button issue in tkinter:
> First I assign the IntVar:
> var = []
> while i < self.something:
>      var.append(IntVar())
>      i += 2
> Later on I use them, but I get this error:
> for r in var:
>      helper = var[r].get()
>      self.something_else[helper] += 1
> Then, this happens:
> Traceback (most recent call last):
>    File "F:\Portable Python 3.2.5.1\App\lib\tkinter\__init__.py", line 1456, in __call__
>      return self.func(*args)
>    File "----(Not giving this)", line 26, in submit_data
>      helper = var[r].get()
> TypeError: list indices must be integers, not IntVar
> I'm willing to give additional info. Thank you in advance.
>

This isn't about radio buttons, it's about how for loops work. I think 
you want:

     for r in var:
         helper = r.get()

The iteration variable in a for loop (r in this case) takes on the 
values of the elements of the list, not the indexes of the elements.

-- 
Ned Batchelder, http://nedbatchelder.com

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

gotta love radio buttons eneskristo@gmail.com - 2014-01-05 10:18 -0800
  Re: gotta love radio buttons Roy Smith <roy@panix.com> - 2014-01-05 13:33 -0500
  Re: gotta love radio buttons Ned Batchelder <ned@nedbatchelder.com> - 2014-01-05 13:37 -0500
  Re: gotta love radio buttons Kev Dwyer <kevin.p.dwyer@gmail.com> - 2014-01-05 18:40 +0000
  Re: gotta love radio buttons eneskristo@gmail.com - 2014-01-05 10:47 -0800
    Re: gotta love radio buttons Gary Herron <gary.herron@islandtraining.com> - 2014-01-05 11:51 -0800
  Re: gotta love radio buttons Gary Herron <gary.herron@islandtraining.com> - 2014-01-05 10:38 -0800

csiph-web