Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable/disable toolbar items?

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?

like image 829
david4dev Avatar asked Nov 14 '10 21:11

david4dev


1 Answers

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).

like image 154
Eduardo Dobay Avatar answered Nov 13 '22 09:11

Eduardo Dobay