How do you make a gtk.ToolButton disabled so that it is 'greyed out'? Like this:
How do you make it enabled again?
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With