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
_______________________________________________
Sugar mailing list
[email protected]
http://lists.laptop.org/listinfo/sugar