PyGTK 中的小部件透明度?
在 PyGTK 应用程序中保持特定小部件透明度的最佳方法是什么?我不想使用主题,因为每个小部件的透明度都会通过动画改变。
我唯一能找到的是使用 cairo 用 Alpha 绘制小部件,但我不知道如何做到这一点。也许还有更好的方法来做到这一点吗?
谢谢!
What is the best way to have transparency of specific widgets in a PyGTK application? I do not want to use themes because the transparency of each of the widgets will be changing through animation.
The only thing I can find is to use cairo to draw widgets with an Alpha, but I can't figure out how to do this. Is there perhaps a better way to do this as well?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您的程序在合成管理器下运行,您可以通过操作小部件的 X 窗口来获得每个小部件的透明度。看看 gtk.gdk.Window.set_opacity ()。
注意,它不是
gtk.Window
;你可以通过获取它的window
属性 (buttonWidget.window
) 来获取这个对象,但只有当 widget 被实现并且只有当 widget 处理事件时—— gtk.Label 不处理事件例如,有自己的 X 窗口。如果您在没有合成管理器的情况下也需要工作,那么自己绘制小部件是唯一的选择 - 但您不一定必须使用 cairo;在裸露的 X 窗口上逐像素绘制也可以。
Assuming that your program runs under composition manager, you could get per-widget transparency by manipulating widget's X window. Look at gtk.gdk.Window.set_opacity().
Note, it is not
gtk.Window
; you can get this object by getting itswindow
property (buttonWidget.window
), but only when widget is realized and only when widget does handle events -- gtk.Label does not have its own X window for instance.If you need to work also when you don't have composition manager, drawing your widgets by yourself is the only option -- but you don't necessarily have to use cairo; drawing pixel by pixel on the bare X window will also work.