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


Groups > comp.lang.python > #41682

Re: Global NameError Fix?

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <drobinow@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.010
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; '21,': 0.07; 'tkinter': 0.07; 'python': 0.09; 'be:': 0.09; 'nameerror:': 0.09; 'def': 0.10; 'tk()': 0.16; 'wrote:': 0.17; 'fix': 0.17; 'thu,': 0.17; 'import': 0.21; 'defined': 0.22; 'header:In-Reply-To:1': 0.25; 'message-id:@mail.gmail.com': 0.27; 'skip:_ 10': 0.29; 'class': 0.29; "i'm": 0.29; "skip:' 10": 0.30; 'window': 0.30; 'to:addr :python-list': 0.33; 'version': 0.34; 'received:google.com': 0.34; 'text': 0.34; 'pm,': 0.35; 'subject:?': 0.35; 'received:209.85': 0.35; 'should': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'hello,': 0.39; 'here': 0.65; '2013': 0.84; 'subject:Global': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=LU3+iISiBRHM/JvZd5ZOqb2SNxQPwqbgtWYIce8QCxg=; b=WujUuUXsVl+3RmQIZYLwQEKX/44koNOcPslYtNmXuN5xcN5w5Eoh03z6WhhJcq4iaG OpDSeqTBQ0iBRgyN2Pzo5JKLSZVeAneq4H36nytuxQQzDQC4nPqdZ2yDjjWSkVJmFYU9 tR7OLgQYb2gNPIgOoXO9pWD+J/+97kSF9qWzpUXXi2xs96Vb7KZBrW/woNp4G5N2x4wk p4+kxDDqqm5FSZuz853WFB7DyE/BFsJ+fERKcJI1tvwUYqS+m3tE+WXVZtKrkWoCa7Dh stnAUSIoJ9w809Ejvz331EsxjijcgG3OdOEe8EunpWcwohujJgj6U45huqdPHZHVmeL9 yHAA==
MIME-Version 1.0
X-Received by 10.60.8.97 with SMTP id q1mr8673243oea.78.1363914254641; Thu, 21 Mar 2013 18:04:14 -0700 (PDT)
In-Reply-To <44451203-05be-4336-9325-c956b0ee2116@googlegroups.com>
References <44451203-05be-4336-9325-c956b0ee2116@googlegroups.com>
Date Thu, 21 Mar 2013 21:04:14 -0400
Subject Re: Global NameError Fix?
From David Robinow <drobinow@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=UTF-8
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 <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3609.1363914257.2939.python-list@python.org> (permalink)
Lines 25
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1363914257 news.xs4all.nl 6853 [2001:888:2000:d::a6]:33064
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:41682

Show key headers only | View raw


On Thu, Mar 21, 2013 at 7:43 PM, maiden129 <sengokubasarafever@gmail.com> wrote:
> Hello,
>
> I'm using the version 3.2.3 of Python and I am having an issue in my program and I don't know how to fix it:
>
> counterLabel["text"] = str(counter)
> NameError: global name 'counterLabel' is not defined
>
> Here is my program:
>
> from tkinter import *
> class CounterButton(Button):
>     def __init__(self, window):
>        super(CounterButton,self).__init__(window, text = "0", command=self.startCounter)
>
>     def startCounter(self):
>         counter = int(self["text"])
>         counter +=1
>         counterLabel["text"] = str(counter)
This should be:
           self["text"] = str(counter)
>
> window = Tk()
> window.title("counter")
...

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


Thread

Global NameError Fix? maiden129 <sengokubasarafever@gmail.com> - 2013-03-21 16:43 -0700
  Re: Global NameError Fix? Dave Angel <davea@davea.name> - 2013-03-21 20:24 -0400
    Re: Global NameError Fix? Rick Johnson <rantingrickjohnson@gmail.com> - 2013-03-22 10:21 -0700
  Re: Global NameError Fix? David Robinow <drobinow@gmail.com> - 2013-03-21 21:04 -0400

csiph-web