开发者

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/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜