Gary Herron wrote:

On Monday 08 December 2003 09:57 am, Jeff Bowden wrote:


Sorry if this is a dupe but my message from last night didn't seem to
make it on to the list.

I'm trying to figure out how to use gtk.gdk.Pixbuf in such a way that it
doesn't consume all the memory in the system.  Part of my app is a list
of thumbnail views of pictures each of which I create with sequence that
look like this:

for image_path in images:
   pb = gtk.gdk.pixbuf_new_from_file(image_path)
   npb = pb.scale_simple(thumb_width, thumb_height,
gtk.gdk.INTERP_BILINEAR)
   thumb_list_model.set_value(thumb_list_model.append(None), 0, npb)

The problem is that memory consumption seems to grow rapidly without
bound making it useless for anything more than a half a dozen or so images.



I hit this recently in a similar situation. My solution (actually it's a workaround) was to use PIL (the Python Image Library) to read and maniuplate the images. It's easy to draw a PIL image to a window:


image = Image.open('...') simage = image.resize((...,...)) window.clear() window.draw_rgb_image(... various parameters..., gtk.gdk.RGB_DITHER_NONE, simage.tostring(), -1, 0, 0)

I can do this process all day and not consume memory.

I'd prefer a solution, but this works fine for now.




Doesn't seem like that would work directly for my use of the GTK TreeView. Hmmm, I wonder which will be more difficult, debugging pygtk or making a custom cell renderer using PIL? Well, debugging seems like the *right* solution so I think I'll try it first.


Are the pygtk developers on this list or is there a separate dev list somewhere?



_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to