Use the set_sensitive method. If you only need to disable / enable the button, you must call the method on the button; the argument must be True to enable and False to disable:
button.set_sensitive(True)
If you are dealing with actions, you can disable / activate the action associated with the button (this ensures that other widgets that can be associated with the same actions, for example, menu items, are also enabled / disabled) and call the method set_sensitive in gtk.Action instead (although this is another method from gtk.Widget one, the use is exactly the same, except that the button will not be enabled if the parent gtk.ActionGroup disabled).
Eduardo doby
source share