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)

window = Tk()
window.title("counter")


counterButton1 = CounterButton(window)
counterButton2 = CounterButton(window)


counterButton1.pack()
counterButton1.pack()


window.mainloop()
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to