[Etoys] Viewing a preview

Walter Bender walter.bender at gmail.com
Sat Jan 17 20:04:51 EST 2009


Here is the Python/GTK way to do this, for what it is worth:

from sugar.datastore import datastore
...
        #my_dsobject is of type datastore.DSObject
        #object_id is a datastore object
        my_dsobject = datastore.get(object_id)

        pixbufloader = gtk.gdk.pixbuf_loader_new_with_mime_type('image/png')
        #Access the 'preview' property
        #Note that the preview image is 300x225
        pixbufloader.write(dsobject.metadata['preview'])
        pixbufloader.close()
        pixbuf = pixbufloader.get_pixbuf()

-walter

On Sat, Jan 17, 2009 at 9:40 AM, Karl Ramberg <karlramberg at gmail.com> wrote:
> Hi,
> I'm testing out stuff in my JournalMorph but run into stuff I can't
> figure out.
>
> I'm trying to view a png preview stored in a ByteArray but I don't get
> it to work.
> I make the ByteArray a RWBinaryOrTextStream but the
> PNGReadWriter formFromStream: aStream do not recognize the format.
>
> I'm not sure how to proceed.
>
> I also tried to write out a png to the Journal but that would not work
> either :-(
>
> Karl
>
>
>
> _______________________________________________
> Etoys mailing list
> Etoys at lists.laptop.org
> http://lists.laptop.org/listinfo/etoys
>



-- 
Walter Bender
Sugar Labs
http://www.sugarlabs.org



More information about the etoys-dev mailing list