Search code examples
python-2.7tkinterattributeerror

Tkinter Attribute Error in __getattr__


I've been trying to open up a Tkinter window to create a simple autoclicker, but I'm stuck on the initialization part.

class Application(Tkinter.Tk):

    def initialize(self):
        self.grid()    

    def __init__(self,parent):
        Tkinter.Tk.__init__(self,parent)
        self.parent = parent
        self.initalize()

if __name__ == '__main__':    
    app = Application(None)
    app.title('clicker')
    app.mainloop()  

When I run this with "python clicker.py" I get this error

Traceback (most recent call last):
  File "clicker.py", line 39, in <module>
    app = Application(None)
  File "clicker.py", line 27, in __init__
    self.initalize()
  File "C:\Python27\lib\lib-tk\Tkinter.py", line 1899, in __getattr__
    return getattr(self.tk, attr)
AttributeError: initalize

Any ideas?


Solution

  • You misspelled your method name. instead of initalize write initialize.

    Since you don't have a method called initalize you got an attribute error message.