The problem is that the gallery code contradicts expectations!
you could have
(image, cond)
or
(images, cond, thumbnail)
But the latter seems to be undocumented, and naturally it's not obvious that in the first instance the image filename is used to generate a thumbnail filename, but in the latter instance the thumbnail must be separately named and placed as the last item in the tuple.
IMO it should be coded (and documented) so that
(thumbnail, cond, images) is the second possibility.
This would make it consistent with the first case (where the first item's name is also used to generate a thumbnail filename), and reduce confusion..
Let's see..
Code: Select all
# Otherwise, get the filename and spec and see if
# we've unlocked it.
if len(images[i]) == 2:
filename, spec = images[i]
toshow = filename
elif len(images[i]) == 3:
filename, spec, toshow = images[i]
if spec:
spec = spec.split()
if spec and tuple(spec) not in persistent._seen_images:
filename = None
clicked = None
else:
clicked = ui.returns(('show', toshow))
^^^ modified version of those lines that does exactly what I said it should do.
Of course, the ideal design probably is
(cond, thumbimage, images)
With 'images' simply being optional.
The advantage of this is that it lets you define things in a somewhat english readable way:
If COND, Show THUMBIMAGE. When THUMBIMAGE is clicked, show either the IMAGES, if available, or the non thumbnail version of the THUMBIMAGE.
(the parameters above appear in the order they do in the sentence.
If you find that preferable, here's a version of those lines of code which implements it:
Code: Select all
# Otherwise, get the filename and spec and see if
# we've unlocked it.
spec, filename = images[i][:2]
if len(images[i]) == 3:
toshow = images[i][2]
else:
toshow = filename
if spec:
spec = spec.split()
if spec and tuple(spec) not in persistent._seen_images:
filename = None
clicked = None
else:
clicked = ui.returns(('show', toshow))