[pygtk] Apply button behavior with GtkDialog
John Dennis
jdennis at redhat.com
Thu Feb 28 06:38:41 WST 2008
Mitko Haralanov wrote:
> In the application that I am working on, I have a GtkDialog with three
> action buttons: Apply, Cancel, and OK. All three buttons return a
> GTK_RESPONSE when clicked (I am using the GtkDialog's run method).
>
> When the user presses the OK or CANCEL buttons everything is fine,
> since on those button presses the dialog window gets closed. However,
> the APPLY button is a different story.
>
> On a click of the APPLY button, the dialog returns the
> GTK_RESPONSE_APPLY response ID (which allows me to perform the actions
> that are associated with that button), however after that none of the
> buttons do anything.
> This makes sense since the run() method returned but the question that
> I have is how do I make the GtkDialog responsive again? Calling the
> dialogs' run() method doesn't work and I don't want to destoy and
> re-create it.
Don't add the "apply" button as an action button. Action buttons always
emit a response and close the dialog. Instead add the apply button as a
normal button widget to the action_area and connect it's 'clicked'
signal to the apply() method of the dialog. I presume you also want to
apply the action if the user clicks OK, to accomplish that trap the
response and if its OK then call your apply(), e.g.:
dlg.connect('response', self.on_response)
def on_response(self, dialog, response):
if response == gtk.RESPONSE_OK:
self.apply()
--
John Dennis <jdennis at redhat.com>
More information about the pygtk
mailing list