[Sugar-devel] ObjectChooser() Issue?
Sascha Silbe
sascha-ml-reply-to-2010-3 at silbe.org
Sun Nov 14 18:00:09 EST 2010
Excerpts from Art Hunkins's message of Sun Nov 14 23:20:49 +0100 2010:
> #Declarations
> self.file = [0, 0, 0, 0]
> self.fileflag = ["0", "0", "0", "0"]
FWIW, this looks rather strange. You might want to choose a different
approach once you got the Object Chooser part working.
> def choose1(self, widget):
> chooser = ObjectChooser(parent=self, what_filter=mime.GENERIC_TYPE_AUDIO)
> result = chooser.run()
> if result == gtk.RESPONSE_ACCEPT:
> jobject = chooser.get_selected_object()
> if jobject and jobject.file_path:
> self.file[0] = jobject.get_file_path()
> open(self.file[0], "r")
Why do you open the file if you're not going to use it? If you'd like
to check for existence, you can use os.path.exists(). This shouldn't
be necessary, however - if the chooser returns an incorrect path, that's
a major bug.
> self.fileflag[0] = "1"
> else:
> self.fileflag[0] = "0"
> close(self.file[0])
Where is close() defined? Why would you want to call close(0) if the
Object Chooser was aborted?
> The jobject is being selected just fine; the problem is, it is still being
> deleted, even though I'm trying to store its path.
That's exactly the problem: You need to store the _DSObject_ instance,
not just the path to the file.
> Please note that there are up to *4* of these choosers (the reason why
> self.file is a list); obviously the various jobjects may well
> replace/interfere with each other.
I don't think the current Journal code handles multiple simultaneous
invocations of the Object Chooser particularly well (from a UI PoV).
Or do you mean to say the user can choose up to four different objects
one at a time? Then you should probably start with an empty list. Or
if the user can choose one each from four different types of objects
(say a background image and a sprite if you were dealing with images
instead of sounds) you might store them in individual variables
instead, initialised with None.
Sascha
--
http://sascha.silbe.org/
http://www.infra-silbe.de/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20101115/552f2b7b/attachment.pgp>
More information about the Sugar-devel
mailing list