Exit frame and panel from panel method
I have a wxPython frame, with a Panel. In my Panel class, I have a method which i开发者_如何转开发s called when a button on that panel is pressed. How can I close the Frame, and the containing panel?
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/
精彩评论