Glade 3 Standard Button Layout

谁说我不能喝 提交于 2019-12-12 01:57:20

问题


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


回答1:


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()


来源:https://stackoverflow.com/questions/2725810/glade-3-standard-button-layout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!