禁用 gtkbutton 的发光效果
我想知道如何禁用鼠标悬停时 gtkButton 的发光效果。 请帮我。
先感谢您。
I would like to know that how to disable the glow effect of gtkButton on mouseover.
Please help me.
Thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这可能就是您正在寻找的。它是 C++,但希望您可以将其翻译为等效的 Python。该代码会更改不同状态下小部件的背景颜色。
您有兴趣在 STATE_PRELIGHT 块中设置正确的颜色,以便它们与 STATE_NORMAL 块中的颜色相同。 (我猜这就是你问题的意思)。
顺便说一句,还有另外两个状态在上面的方法中没有处理:STATE_SELECTED 和 STATE_INSENSITIVE。还必须指出的是,该函数尽管有其名称,但实际上并不会更改任何小部件的颜色。例如,它不会更改标签的颜色,因为标签采用其容器的颜色。所以不要太认真地对待函数签名。
This may be what you are looking for. It is c++, but hopefully you can translate it to the python equivalent. The code changes the background color of a widget in different states.
You are interested in setting the right colors in the STATE_PRELIGHT block so that they are the same than in the STATE_NORMAL block. (I'm guessing this is what you mean with your question).
By the way, there are two other states which are not handled in the method above: STATE_SELECTED and STATE_INSENSITIVE. It must also be stated that this function, despite its name, doesn´t actually change the color of any widget. It won't change the color of a label, for example, since a label takes the color of it's container. So don't take the function signature too seriously.
以下Python代码将复制按钮的样式,将
gtk.STATE_PRELIGHT
(鼠标悬停)状态下的背景颜色设置为与gtk.STATE_NORMAL
相同的颜色,并然后将样式设置回小部件上。由于这不会干扰按钮的实际状态,因此对其余代码没有副作用。
此代码可能会对 GDK 主题产生影响。如果我发现一个主题安全的方法,我将编辑我的答案。
The following Python code will make a copy of the button's style, set the background color in the
gtk.STATE_PRELIGHT
(mouseover) state to the same color asgtk.STATE_NORMAL
, and then set the style back on the widget.Since this doesn't mess with the actual state of the button, there are no side effects to the rest of your code.
This code MAY have the an affect on GDK themes. If I discover a theme-safe method for this I will edit my answer.