I create a Dialog, and at some point I need to toggle sensitive flag of OK button (gtk.STOCK_OK). I successfully access action_area and buttons in it, but how do I identify the OK button?
Also, is there a simpler way to enable/disable OK button?
Thanks.
Using the label should work, but it’s very fragile; translations will probably break it, and your positive-response buttons won’t always be called “OK” anyway. You should consider using the response ID to identify the appropriate button instead. For example, a typical OK button might be created using:
You can then retrieve your OK button later using the
get_widget_for_responsecall, which seems perfectly designed to do exactly what you want to do:I’d suggest that this is probably the way you should do it; it’s similar to the way that the
set_alternative_button_order()API works, which suggests that it’s what was intended.