response = dialog.run()
if response == gtk.RESPONSE_OK:
#do something here if the user hit the OK button
dialog.destroy()
第二个允许您在非阻塞的东西中使用对话框,然后您必须将对话框连接到“响应”信号 .
def do_response(dialog, response):
if response == gtk.RESPONSE_OK:
#do something here if the user hit the OK button
dialog.destroy()
dialog.connect('response', do_response)
现在,您注意到必须销毁对话框
5
当您收到删除或取消信号时,您需要调用窗口小部件的hide()方法:
response = self.wTree.get_widget("aboutdialog1").run() # or however you run it
if response == gtk.RESPONSE_DELETE_EVENT or response == gtk.RESPONSE_CANCEL:
self.wTree.get_widget("aboutdialog1").hide()
2 回答
与任何其他对话窗口一样,它们需要您
使用run方法 .
使用"reponse"信号
第一个将阻止主循环并在对话框收到响应后立即返回,这可能是,单击操作区域中的任何按钮或按Esc,或调用对话框的响应方法或“销毁”窗口,最后一个并不意味着窗口将被销毁,这意味着run()方法将退出并返回响应 . 像这样:
如果使用调试器,您会注意到主循环保持不变,直到您单击按钮或尝试关闭对话框 . 收到您的回复后,您就可以根据需要使用 .
第二个允许您在非阻塞的东西中使用对话框,然后您必须将对话框连接到“响应”信号 .
现在,您注意到必须销毁对话框
当您收到删除或取消信号时,您需要调用窗口小部件的hide()方法:
你可以找到响应类型常量in the GTK documentation