sugar4.graphics.objectchooser
STABLE.
Attributes
Classes
UI interface for object choosers. |
Functions
|
Retrieve a pixbuf with the content of the preview field |
Module Contents
- sugar4.graphics.objectchooser.get_preview_pixbuf(preview_data, width=-1, height=-1)[source]
Retrieve a pixbuf with the content of the preview field
- Parameters:
preview_data (bytes) – preview data from the metadata dictionary. Can’t be None. Returned from the sugar4.datastore.datastore.DSObject.get_metadata() method.
- Keyword Arguments:
- Returns:
the generated Pixbuf None: if it could not be created
- Return type:
GdkPixbuf.Pixbuf
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.append(im) im.show()
- class sugar4.graphics.objectchooser.ObjectChooser(parent=None, what_filter=None, filter_type=None, show_preview=False)[source]
Bases:
objectUI interface for object choosers.
Object choosers can be used by activities to allow the user to select objects from the file system or from some other similar source.
- Keyword Arguments:
parent (
Gtk.Widget) – the widget calling ObjectChooserwhat_filter (str) – an activity bundle_id or a generic mime type as defined in
sugar4.mimeused to determine which objects will be presented in the object chooserfilter_type (str) –
should be one of [None, FILTER_TYPE_GENERIC_MIME, FILTER_TYPE_ACTIVITY, FILTER_TYPE_MIME_BY_ACTIVITY]
If filter_type is None, the default behavior of the what_filter is applied (for backward compatibility), this option is DEPRECATED.
If filter_type is FILTER_TYPE_GENERIC_MIME, the what_filter should be a generic mime type defined in mime.py; the object chooser will filter based in the ‘mime_type’ metadata field.
If filter_type is FILTER_TYPE_ACTIVITY, the what_filter should by an activity bundle_id; the object chooser will filter based in the ‘activity’ metadata field.
If filter_type is FILTER_TYPE_MIME_BY_ACTIVITY, the what_filter should be an activity bundle_id; the object chooser will filter based on the ‘mime_type’ metadata field and the mime types defined by the activity in the activity.info file.
show_preview (bool) – if True will show the preview image associated with the object in the Journal. This option is only available if filter_type is selected.
Examples
chooser = ObjectChooser(self._activity, what_filter=’Image’)
- chooser = ObjectChooser(parent=self,
what_filter=self.get_bundle_id(), filter_type=FILTER_TYPE_ACTIVITY)
- run()[source]
Runs the object chooser and displays it.
- Returns:
Gtk.ResponseType constant, the response received from displaying the object chooser.