Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'assign': 0.07; 'error:': 0.07; 'indices': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'integers,': 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; 'index': 0.16; 'wrote:': 0.18; 'advance.': 0.19; 'later': 0.20; 'header:User-Agent:1': 0.23; 'helper': 0.24; 'header:X-Complaints- To:1': 0.27; "i'm": 0.30; 'info.': 0.31; 'file': 0.32; '(most': 0.33; 'but': 0.35; 'var': 0.36; 'so,': 0.37; 'list': 0.37; 'list.': 0.37; 'button': 0.38; 'thank': 0.38; 'to:addr:python- list': 0.38; 'issue': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'radio': 0.60; 'then,': 0.60; 'first': 0.61; 'email addr:gmail.com': 0.63; 'header:Reply-To:1': 0.67; '26,': 0.68; 'reply-to:no real name:2**0': 0.71; 'reply- to:addr:gmail.com': 0.80 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Kev Dwyer Subject: Re: gotta love radio buttons Date: Sun, 05 Jan 2014 18:40:41 +0000 References: <8dca57e8-8258-4020-9788-987af332b5b2@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Gmane-NNTP-Posting-Host: cpc5-hari13-2-0-cust222.20-2.cable.virginm.net Mail-Copies-To: kevin.p.dwyer@gmail.com User-Agent: KNode/4.7.2 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: kevin.p.dwyer@gmail.com List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1388947262 news.xs4all.nl 2849 [2001:888:2000:d::a6]:42748 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:63208 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. (untested) for r in var: helper = var[r.get()] I think you need to call get on the IntVar instance to get an int that can be used to index the list.