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, eg 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).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.