Philip
Philip

Reputation: 301

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 that I can draw at runtime?

Greets, Philip

Upvotes: 2

Views: 518

Answers (1)

Philip
Philip

Reputation: 301

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... :-|

Upvotes: 4

Related Questions