问题描述
我想用Glade 3(或者gtk和Python)创建一个对话框。在Glade 2中,如果你想创建一个对话框,可以选择设置一个标准按钮布局,它会自动创建一个Ok按钮和一个返回gtk.RESPONSE_OK或gtk.REPONSE_CANCEL的Cancel按钮。此功能尚未在Glade 3中重新展示。
如何创建一个对话框,其中包含ok和cancel按钮,以返回正确的响应?
$ b
干杯,
Pete
您可以在Glade中手动创建它们;答复代码可能只能设置为一个数字。你需要的数字是:OK是-5,取消是-6。
或者你可以在代码中创建它:
dialog = gtk.MessageDialog(flags = gtk.DIALOG_MODAL,
buttons = gtk.BUTTONS_OK_CANCEL,
message_format ='您确定要对样条进行网格化吗?')
response = dialog .run()
dialog.destroy()
I want to create a dialog using Glade 3 (or gtk and Python). In Glade 2 if you wanted to create a dialog box there was an option to set a "standard button layout" which would automatically create an Ok button and a Cancel button which return either gtk.RESPONSE_OK or gtk.REPONSE_CANCEL. This feature has not been reimplmented in Glade 3.
How can I create a dialog which will have ok and cancel buttons which return the correct response?
Cheers,
Pete
You can create them manually in Glade; the response code can unfortunately only be set to a number. The numbers you need are here: OK is -5, Cancel is -6.
Or you can create it in code:
dialog = gtk.MessageDialog(flags=gtk.DIALOG_MODAL,
buttons=gtk.BUTTONS_OK_CANCEL,
message_format='Are you sure you want to reticulate the splines?')
response = dialog.run()
dialog.destroy()
这篇关于Glade 3标准按钮布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!