7

How do you make a gtk.ToolButton disabled so that it is 'greyed out'? Like this:

alt text

How do you make it enabled again?

david4dev
  • 4,854
  • 2
  • 28
  • 35

1 Answers1

13

Use the set_sensitive method. If all you need is to disable/enable the button, you should call the method on the button; the argument should be True for enabling and False for disabling:

button.set_sensitive(True)    # enables the button
button.set_sensitive(False)   # disables the button

If you are dealing with actions, you may want to disable/enable the action associated to the button (this ensures that other widgets that may be related to the same actions, e.g. menu items, are enabled/disabled too), and call the set_sensitive method on the gtk.Action instead (although this is a different method from the gtk.Widget one, the usage is exactly the same; except that the button will not be enabled if the parent gtk.ActionGroup is disabled).

Eduardo Dobay
  • 695
  • 1
  • 7
  • 15