问题
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