Indentation Error -Python frames
Question: Can someone look what is the problem with this code..Everything looks good for
me but I get indentation error.

The code below creates a new frame and contains a button.. WHen the button is
clicked a event is triggered and displays more information about the parent
and child..

Code:

    
    
    import wx
    class MyApp(wx.App):
        def OnInit(self):
            self.frame = MyFrame(None, title="The Main Frame")
            self.SetTopWindow(self.frame)
            self.frame.Show()
            return True
    
    class MyFrame(wx.Frame):
        def __init__(self, parent, id=wx.ID_ANY, title="", 
                     pos=wx.DefaultPosition, size=wx.DefaultSize,
                     style=wx.DEFAULT_FRAME_STYLE,
                     name="MyFrame"):
            super(MyFrame, self).__init__(parent, id, title,
                                          pos, size, style, name)
            # Attributes
            self.panel = wx.Panel(self)
            self.panel.SetBackgroundColour(wx.BLACK)
            self.button = wx.Button(self.panel,
                                    label="Push Me",
                                    pos=(50, 50))
            self.btnId = button.GetId()
            # Event Handlers
            self.Bind(wx.EVT_BUTTON, self.OnButton, button)
    
        def OnButton(self, event):
            """Called when the Button is clicked"""
            print "\nFrame GetChildren:"
            for child in self.GetChildren():
                print "%s" % repr(child)
            print "\nPanel FindWindowById:"
            button = self.panel.FindWindowById(self.btnId)
            print "%s" % repr(button)
            # Change the Button's label
            button.SetLabel("Changed Label")
            print "\nButton GetParent:"
            panel = button.GetParent()
            print "%s" % repr(panel)
            print "\nGet the Application Object:"
            app = wx.GetApp()
            print "%s" % repr(app)
            print "\nGet the Frame from the App:"
            frame = app.GetTopWindow()
            print "%s" % repr(frame)
    
    if __name__ == "__main__":
        app = MyApp(False)
        app.MainLoop()  
    

Here is the error:

    
    
    C:\Python27\wx>python frame_new.py
      File "frame_new.py", line 22
        self.btnId = button.GetId()
        ^
    IndentationError: unexpected indent                         
    


Answer: Open the file in some program that can show tabs and spaces, such as Notepad++
on Windows. Then you can see if you have some kind of tab / space mix or
something.

