Creating RGBA Colormap in PyGTK

I have a project in Python 2.7 and PyGTK.

I need to create a transparent background window, but still be able to display images (pixmap and mask based) and other objects inside the window.

I use the following code, but image objects are not displayed in Ubuntu (Oneric Ocelot), and I get the error message posted below (although otherwise the window displays buttons with its objects). This will not even appear on Windows 7 (this error is also listed below).

def expose(widget, event): cr = widget.window.cairo_create() # Sets the operator to clear which deletes everything below where an object is drawn cr.set_operator(cairo.OPERATOR_CLEAR) # Makes the mask fill the entire window cr.rectangle(0.0, 0.0, *widget.get_size()) # Deletes everything in the window (since the compositing operator is clear and mask fills the entire window cr.fill() # Set the compositing operator back to the default cr.set_operator(cairo.OPERATOR_OVER) hab_fish_win = gtk.Window() hab_fish_win.resize(640, 480) hab_fish_win.set_resizable(False) hab_fish_win.set_decorated(False) hab_fish_win.set_has_frame(False) hab_fish_win.set_position(gtk.WIN_POS_CENTER) hab_fish_win.set_app_paintable(True) screen = hab_fish_win.get_screen() rgba = screen.get_rgba_colormap() hab_fish_win.set_colormap(rgba) hab_fish_win.connect('expose-event', expose) hab_fish_win.show() 

WINDOWS 7 RUN:

Traceback (last last call): File "C: \ Users \ user \ MousePaw Games \ Word4Word \ PYM \ fishtest2.py", line 337, in HAB_FISH () File "C: \ Users \ user \ MousePaw Games \ Word4Word \ PYM \ fishtest2.py ", line 100, in init hab_fish_win.set_colormap (rgba) TypeError: Gtk.Widget.set_colormap () argument 1 must be gtk.gdk.Colormap, not Missing

The quick "print rgba" confirms that rgba is "None", therefore an error.

UBUNTU "ONERIC OCELOT" RUN:

Gtk Warning: try drawing pushed with a depth of 24 to readable with a depth of 32

What's happening? I desperately need a transparent background for the window.

+4
source share
1 answer

Well, after several hours of research, I found that Windows does not support such transparency. As for the Linux error, I do not know.

I port to PyGObject and use a different method for my purposes. I would suggest readers of this answer study it.

+3
source

All Articles