[sugar] filtering result of an object chooser

Erik Blankinship erikb at mediamods.com
Mon Mar 3 15:54:11 EST 2008


On 2/29/08, Erik Blankinship <erikb at mediamods.com> wrote:
>
> Is there a way to filter the mime types of the objects presented with an
> object chooser (e.g., only png)?  Here is some sample code I am using:
>
> import gtk
> import shutil
> from sugar.graphics.objectchooser import ObjectChooser
>
> class FilePicker:
>
>     def __init__(self):
>         pass
>
>     def show(self):
>         title = None
>         parent = None
>         file = None
>         chooser = ObjectChooser(title, parent, gtk.DIALOG_MODAL |
> gtk.DIALOG_DESTROY_WITH_PARENT)
>         try:
>             result = chooser.run()
>             if result == gtk.RESPONSE_ACCEPT:
>                 jobject = chooser.get_selected_object()
>                 if jobject and jobject.file_path:
>                     ext = os.path.splitext(jobject.file_path)[1]
>                     f, new_temp = tempfile.mkstemp(ext)
>                     del f
>
>                     global _temp_files_to_clean
>                     _temp_files_to_clean.append(new_temp)
>                     shutil.copy(jobject.file_path, new_temp)
>
>                     file = new_temp
>         finally:
>             chooser.destroy()
>             del chooser
>
>         return file
>


Unfortunately, this code (and the identical code in the Browse activity)
when run in jhbuild always returns this path: "."

Is this expected behavior?  Is this problem unique to jhbuild?  Is there
something I should to differently?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.laptop.org/pipermail/sugar/attachments/20080303/34cd2883/attachment.htm 


More information about the Sugar mailing list