PDA

View Full Version : Draw to a buffer possible?


ekib
July 21st, 2008, 07:36 PM
Hi all,

I just stumbled upon this widget framework and it looks very promising (especially since I love Python). Nice work!

I had a quick question though. Is it possible to intercept the drawing of widgets and save the drawn widget to a buffer? I would have to do this repeatedly whenever an update occurs. Would this be done at a cairo level and where would I plug something like this in the framework (without having to insert this code in on_draw method for each widget)? The widget ideally wouldn't be drawn on the screen but it could be if there is no other way.

I would appreciate any pointers,
Thanks,
Ratko

ekib
July 23rd, 2008, 01:36 AM
OK, so after some digging through code and gtk/gdk, I added the following to Screenlet.redraw_canvas() method:

w,h = self.window.window.get_size()
buffer = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, w, h)
nb = buffer.get_from_drawable(self.window.window,
self.window.window.get_colormap(),
0, 0, 0, 0, w, h)
if nb:
nb.save("test.jpg", "jpeg")

And it works to some extent... The problem is that I get some weird leftover graphics in the window but around the widget itself (see pic). It seems that there are some leftover pixels when I do get_from_drawable. Anybody know how to fix that? That area is supposed to be transparent no?

Thanks for any help,
R


http://www.evl.uic.edu/rjagodic/pics/test.jpg

aantn
August 17th, 2008, 10:32 PM
Sorry about the delayed reply.

Can you please explain why you need to save the widget to a buffer?