如何启用/禁用工具栏项?
如何禁用 gtk.ToolButton 使其“灰显”?像这样:
如何使其再次启用?
How do you make a gtk.ToolButton disabled so that it is 'greyed out'? Like this:
How do you make it enabled again?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
set_sensitive
方法。如果您只需要禁用/启用按钮,您应该调用按钮上的方法;参数应为True
启用,False
禁用:如果您正在处理操作,您可能需要禁用/启用与按钮关联的操作(这可确保其他可能与相同操作相关的小部件(例如菜单项)也被启用/禁用),并调用
gtk.Action
上的set_sensitive
方法(尽管这与gtk.Widget
方法不同,用法完全相同;只是如果父gtk.ActionGroup
被禁用,按钮将不会启用)。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 beTrue
for enabling andFalse
for disabling: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 thegtk.Action
instead (although this is a different method from thegtk.Widget
one, the usage is exactly the same; except that the button will not be enabled if the parentgtk.ActionGroup
is disabled).