Open main menu
Home
Random
Log in
Settings
About Sugar Labs
Disclaimers
Sugar Labs
Search
Changes
← Older edit
Newer edit →
Development Team/Almanac/sugar.datastore.datastore
(view source)
Revision as of 11:22, 14 January 2009
613 bytes added
,
11:22, 14 January 2009
→How do I access the metadata entries for a datastore object?
Line 146:
Line 146:
print my_dsobject.metadata['description']
print my_dsobject.metadata['description']
+
</pre>
+
This code snippet shows how to create a pixbuf from the preview entry in the datastore:
+
<pre>
+
from sugar.datastore import datastore
+
...
+
#my_dsobject is of type datastore.DSObject
+
#object_id is a datastore object (returned from the datastore Chooser
+
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()
</pre>
</pre>
Walter
Bureaucrats
,
Administrators
10,579
edits