Pygtk:更改小部件的边框颜色
我到处都找过,但似乎找不到改变边框颜色的方法。 例如,我需要一个像这样的按钮:
gb = gtk.Button("Hi")
gb.set_border_width(50)
现在我希望将边框设置为红色(这是一个不存在的调用):
gb.set_border_color('red')
我尝试了 gb.modify_bg(...) 但它仅更改按钮的背景,而不更改 BORDER围绕它。我能得到的最简单的办法就是将此 GtkButton 添加到 GtkFrame 中,并使用框架的阴影颜色。然而,阴影框的宽度是固定的——它是一条低于我所需厚度的细线。
对我来说,直观的是,如果您可以更改边框的宽度,那么您应该能够在其上设置更多样式。我愿意接受其他方法来实现相同的厚彩色边框效果,例如将按钮放在一些大的彩色背景上?
感谢您在这里的任何帮助。
I have looked everywhere but couldn't seem to find a way to change the color of the border.
For example I need a button like this:
gb = gtk.Button("Hi")
gb.set_border_width(50)
Now I wish to color the border red (this is a non-existent call):
gb.set_border_color('red')
I tried gb.modify_bg(...) but it only changes the background of the button, not the BORDER surrounding it. The closet thing I can get is adding this GtkButton to a GtkFrame, and use the frame's shadow color. However the shadow box's width is fixed - it's a thin line way below my desired thickness.
It's intuitive to me that if you can change the width of a border, you should be able to set more styles on it. I am open to other ways to achieve the same thick-colored-border effect, such as laying the button on top of some big, colored background?
Thanks for any help here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AFAIR,gtk.Button 边框处理取决于引擎。如果你不想搞乱样式,你可以创建 gtk.EventBox,设置其背景颜色,打包按钮,然后将按钮周围的空白空间量设置为所需的值:
AFAIR, gtk.Button border handling is engine-dependent. If you don't want to mess with styles, you could create gtk.EventBox, set its background color, pack the button, and then set the amount of empty space around the button to desired value: