[pygtk] Trouble with Composited Windows example in gtk.gdk.Window docs

Neal Holtz nholtz at cee.carleton.ca
Sat May 24 09:00:11 WST 2008


Hi,

I am having trouble getting 
"A gtk.gdk.Window Composited Windows example"
from gtk.gdk.Window in "The gtk.gdk Class Reference"
to work.  This is from the PyGTK 2.0 Reference Manual
"For PyGTK version 2.12.1", "2008-01-03".

When I try to run the example as in the documentation, I get:

> post:V3> python demo2.py
> demo2.py:108: GtkWarning: Attempt to draw a drawable with depth 24 to a drawable with depth 32
>   gtk.main()
> Traceback (most recent call last):
>   File "demo2.py", line 55, in window_expose_event
>     child.allocation.y)
> TypeError: cairo_set_source_pixmap() argument 1 must be gtk.gdk.Pixmap, not gtk.gdk.Window
> Traceback (most recent call last):
>   File "demo2.py", line 55, in window_expose_event
>     child.allocation.y)

The file 'demo2.py' is attached.

In an attempt to correct the second error (at line 55),
I replaced

>     #the source data is the (composited) event box
>     cr.set_source_pixmap (child.window,
>                           child.allocation.x,
>                           child.allocation.y)

with

>     #the source data is the (composited) event box
>     w,h = child.window.get_size()
>     cr.set_source_pixmap (gtk.gdk.Pixmap( child.window, w, h, -1 ),
>                           child.allocation.x,
>                           child.allocation.y)

Now, I get:

> post:V3> python demo2b.py
> demo2b.py:109: GtkWarning: Attempt to draw a drawable with depth 24 to a drawable with depth 32
>   gtk.main()
> Traceback (most recent call last):
>   File "demo2b.py", line 67, in window_expose_event
>     cr.paint_with_alpha(0.5)
> cairo.Error: the target surface has been finished

Changing that last change to:

>   #the source data is the (composited) event box
>   w,h = child.window.get_size()
>   pm = gtk.gdk.Pixmap( child.window, w, h, -1 )
>   cr.set_source_pixmap (pm,
>                         child.allocation.x,
>                         child.allocation.y)

I have now reduced the messages down to one:

> post:V3> python demo2c.py
> demo2c.py:110: GtkWarning: Attempt to draw a drawable with depth 24 to a drawable with depth 32
>   gtk.main()

My questions are:

  1. Why did introducing the the assignment of the pixmap
     to a local variable ('pm') change things, and what
     was the cause of that "the target surface has been finished"
     error?

  2. Why am I still getting the warning about drawing a depth 24 to
     a depth 32?

  3. What is the behaviour of this thing supposed to be?  I don't
     think I get it.  When I mouse over the button, the text
     disappears.  When I try other mods to the code (i.e., add 2
     buttons in an Hbox), I seem to get some random dirt written
     by one of the expose handlers.

I'm using Ubuntu Hardy, with python 2.5.2 and
>>> gtk.ver
(2, 14, 1)
>>> gtk.gtk_version
(2, 12, 9)
>>> gtk.pygtk_version
(2, 12, 1)


-- 
Neal Holtz                            http://cee.carleton.ca/~nholtz
Dept. of Civil and Environmental Engineering     Carleton University
Ottawa, Ontario, Canada K1S 5B6.              nholtz at cee.carleton.ca
Key: http://cee.carleton.ca/~nholtz/pubkey.asc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: demo2.py
Type: application/x-python
Size: 3277 bytes
Desc: not available
Url : http://www.daa.com.au/pipermail/pygtk/attachments/20080523/e40ab04f/demo2.bin


More information about the pygtk mailing list