从面板方法中退出框架和面板
我有一个 wxPython 框架,带有一个面板。在我的面板类中,我有一个方法,当按下该面板上的按钮时会调用该方法。如何关闭框架及其包含的面板?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有几种方法。假设面板的父级是框架,您可以将其作为按钮的处理程序执行此操作:
或者您可以使用 pubsub 将消息“发布”到框架类并告诉它关闭。有关 pubsub 的简单示例,请参阅以下文章: http://www.blog.pythonlibrary.org/2010/06/27/wxpython-and-pubsub-a-simple-tutorial/
There are a couple of approaches. Assuming that the panel's parent is the frame, you could do this as the button's handler:
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/