views:

171

answers:

1

Hey,

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  A: 

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