From c95d74eab4d66eab2c7766eea6c68471223da235 Mon Sep 17 00:00:00 2001 From: mandarj7 Date: Wed, 23 Dec 2015 16:55:25 +0530 Subject: [PATCH] Improve docstrings in sugar3.graphics.objectchooser --- src/sugar3/graphics/objectchooser.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/sugar3/graphics/objectchooser.py b/src/sugar3/graphics/objectchooser.py index 02989427..3428e072 100644 --- a/src/sugar3/graphics/objectchooser.py +++ b/src/sugar3/graphics/objectchooser.py @@ -46,7 +46,9 @@ def get_preview_pixbuf(preview_data, width=-1, height=-1): Retrive a pixbuf with the content of the preview field Args: - metadata (dictionary): the metadata dictionary. Can't be None, use metadata.get('preview', '') + metadata (dictionary): preview data from the metadata dictionary. Can't + be None. Returned from the + sugar3.datastore.datastore.DSObject.get_metadata() method. Keyword Args: width (int): the pixbuf width, if is not set, the default width will be used @@ -55,6 +57,16 @@ def get_preview_pixbuf(preview_data, width=-1, height=-1): Returns: Pixbuf, the generated Pixbuf None, if it could not be created + + Example: + pixbuf = get_preview_pixbuf(metadata.get('preview', '')) + has_preview = pixbuf is not None + + if has_preview: + im = Gtk.Image() + im.set_from_pixbuf(pixbuf) + box.add(im) + im.show() """ if width == -1: width = PREVIEW_SIZE[0] @@ -103,7 +115,7 @@ def get_preview_pixbuf(preview_data, width=-1, height=-1): class ObjectChooser(object): """ - UI interface for objec choosers. + UI interface for object choosers. Object choosers can be used by acivities to allow the user to select objects from the file system or from some other similar source. @@ -112,7 +124,7 @@ class ObjectChooser(object): parent (:class:`Gtk.Widget`): the widget calling ObjectChooser what_filter (str): an activity bundle_id or a generic mime type as - defined in mime.py used to determine which objects + defined in :mod:`sugar3.mime` used to determine which objects will be presented in the object chooser filter_type (str): should be one of [None, FILTER_TYPE_GENERIC_MIME,