开发者

PyGTK StatusIcon with transparency

I'm trying to create a PyGTK StatusIcon with transparent background. I need to draw the contents of the StatusIcon at runtime.

StatusIcon wants a Pixbuf object (which can have transparency). No problem with that:

pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, width, height)
pixbuf.fill(0xffffffff)

The problem is, I can't draw to Pixbuf objects. My current approach is to draw to a Pixmap and then convert it to a Pixbuf, but unfortunately Pixmaps can't have transparency.

How do I get a Pixbuf with transparent background t开发者_如何转开发hat I can draw at runtime?

Greets, Philip


You can add transparency to Pixbuf objects with the add_alpha() method. The following line will set zero opacity for the color #ffffff:

pixbuf = pixbuf.add_alpha(True, 0xFF, 0xFF, 0xFF)

Too easy... :-|

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜