开发者

Exit frame and panel from panel method

开发者 https://www.devze.com 2023-03-21 20:54 出处:网络
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?T

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/

0

精彩评论

暂无评论...
验证码 换一张
取 消