Widget.hide() 的问题
问题:小部件“A”是在主窗口“B”中单击按钮后显示的顶级窗口。如何分配一个处理程序来处理单击小部件“A”窗口边框上的“X”后发回的信号(请参阅下面的当前实现)?
def on_mainWindow_B_button_clicked(self, widget):
self.widget_a.show()
def on_widget_a_destroy(self, widget): #this is the handler I have right now yet after it's called and widget.a closes and 'on_mainWindow_B_button_clicked' is called for the second time none of widget.a's children appear in the new window
widget.hide()
Problem: Widget 'A' is a toplevel window that is displayed after a button click in MainWindow 'B'. How do I assign a handler to handle the signal sent back after the 'X' along the window border of Widget 'A' is clicked (see below for current implementation)?
def on_mainWindow_B_button_clicked(self, widget):
self.widget_a.show()
def on_widget_a_destroy(self, widget): #this is the handler I have right now yet after it's called and widget.a closes and 'on_mainWindow_B_button_clicked' is called for the second time none of widget.a's children appear in the new window
widget.hide()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
delete_event
信号的处理程序必须返回True
才能阻止窗口在关闭时被永久销毁。如果您只想隐藏窗口,可以使用内置快捷方式:
The handler for the
delete_event
signal must returnTrue
in order to stop the Window being permanently destroyed on closing.If you only want to have the window hide, there's a builtin shortcut you can use: