I have a function that creates prompts using gtk.MessageDialog in PyGTK. How could I access the predefined buttons? Or would I need to manually construct a gtk.Dialog? I'd rather not, seeing as MessageDialog is a convenience function.
The function:
def gtkPrompt(self, name):
# Create new GTK dialog with all the fixings
prompt = gtk.MessageDialog(None, 0, gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK_CANCEL, name)
# Set title of dialog
prompt.set_title("Prompt")
# Create and add entry box to dialog
entry = gtk.Entry()
prompt.vbox.add(entry)
# Show all widgets in prompt
prompt.show_all()
# Run dialog until user clicks OK or Cancel
if prompt.run() == gtk.RESPONSE_CANCEL:
# User cancelled dialog
rval = False
else:
# User clicked OK, grab text from entry box
rval = entry.get_text()
# Destory prompt
prompt.destroy()
# Give the good (or bad) news
return rval