Class name not defined even after stating it
Question: I'm new to python GUI programming and went through this tutorial stating
Tkinter uses

I tried the following code

    
    
    import Tkinter
    
    class  simpleapp_tk(Tkinter.Tk):
         def __init__(self,parent):
               Tkinter.Tk.__init__(self,parent)
               self.parent=parent
               self.initialize()
    
      def initialize(self):
            pass
      if  __name__=="__main__":
            app=simpleapp_tk(None)
            app.title('my application')
            app.mainloop()
    

I expected a blank window but instead got this

    
    
     Traceback (most recent call last):
      File "C:/Users/vedev/Desktop/python/app1.py", line 3, in <module>
        class  simpleapp_tk(Tkinter.Tk):
      File "C:/Users/vedev/Desktop/python/app1.py", line 12, in simpleapp_tk
    app=simpleapp_tk(None)
    NameError: name 'simpleapp_tk' is not defined
    

How do i debug it?


Answer: It's a problem with your indentation. Just don't indent

    
    
    if __name__ == "__main__":
        app = simpleapp_tk(None)
        app.title('my application')
        app.mainloop()
    

In your current code the if statement is executed while `simpleapp_tk` is
being defined, thus `name 'simpleapp_tk' is not defined`.

See
[Indentation](https://docs.python.org/2/reference/lexical_analysis.html#indentation)

> Leading whitespace (spaces and tabs) at the beginning of a logical line is
> used to compute the indentation level of the line, which in turn is used to
> determine the grouping of statements.

