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


Groups > comp.lang.python > #41682

Re: Global NameError Fix?

References <44451203-05be-4336-9325-c956b0ee2116@googlegroups.com>
Date 2013-03-21 21:04 -0400
Subject Re: Global NameError Fix?
From David Robinow <drobinow@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.3609.1363914257.2939.python-list@python.org> (permalink)

Show all headers | 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