user825286
user825286

Reputation:

Exit frame and panel from panel method

I have a wxPython frame, with a Panel. In my Panel class, I have a method which is called when a button on that panel is pressed. How can I close the Frame, and the containing panel?

Upvotes: 0

Views: 819

Answers (1)

Mike Driscoll
Mike Driscoll

Reputation: 33071

There are a couple of approaches. Assuming that the panel's parent is the frame, you could do this as the button's handler:

def onClose(self, event):
   frame = self.GetParent()
   frame.Close()

Or you could use pubsub to "publish" a message to the frame class and tell it to close. See the following article fora simple example of pubsub: http://www.blog.pythonlibrary.org/2010/06/27/wxpython-and-pubsub-a-simple-tutorial/

Upvotes: 1

Related Questions