> On Sun, Jan 30, 2005 at 11:10:36AM +0100, Nemesis wrote:
> > I think that some methods like gtk.Image.set_from_file() should accept
> > as argument not only the filename as string but also a file object.
> 
> I disagree. As it is, there is a fairly straightforward mapping
> between pygtk and the underlying GTK+ C API. gtk_image_set_from_file()
> takes a string that is a file name. Passing a file object is a major
> semantic difference, and it would not be possible to write a wrapper for
> gtk_image_set_from_file() from a file object, it would be a totally
> different function from its C counterpart.

I don't want to break the API mapping. Maybe it is possible to add a
pygtk only method (If I remember correctly there are already such methods
for treeviews).

For example a gtk.Image.set_from_file_object()
> I think what you want can be done with a gtk.gdk.PixbufLoader or
> possibly one of the gtk.gdk.pixbuf_new_from constructors. Then you can
> use gtk.Image.set_from_pixbuf().

You are right, the solution is PixbufLoader it can take a buffer and
write it to a pixbuf.
Maybe the the gtk.Image.set_from_file_object() could be a wrapper for
this solution. Something like this:

def set_from_file_object(self,file_object,image_format=None):
    buffer=file_object.read()
    pixbuf_loader=gtk.gdk.PixbufLoader(image_format)
    pixbuf_loader.write(buffer)
    pixbuf_loader.close()
    pixbuf=pixbuf_loader.get_pixbuf()
    self.set_from_pixbuf(pixbuf)

-- 
GMX im TV ... Die Gedanken sind frei ... Schon gesehen?
Jetzt Spot online ansehen: http://www.gmx.net/de/go/tv-spot
_______________________________________________
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