Even with the sample images directory used for this book, we lost the Quit button at
the bottom of the display in the last two figures because there are too many thumbnail
images to show. To illustrate the difference, the original Example 8-45 packs the Quit
button first for this very reason—so it is clipped last, after all thumbnails, and thus
remains visible when there are many photos. We could do a similar thing for the other
versions, but we’d still lose thumbnails if there were too many. A directory from your
camera with many images might similarly produce a window too large to fit on your
computer’s screen.
To do better, we could arrange the thumbnails on a widget that supports scrolling. The
open source Pmw package includes a handy scrolled frame that may help. Moreover,
the standard tkinter Canvas widget gives us more control over image displays (including
placement by absolute pixel coordinates) and supports horizontal and vertical scrolling
of its content.
In fact, in the next chapter, we’ll code one final extension to our script which does just
that—it displays thumbnails in a scrolled canvas, and so it handles large collections
much better. Its thumbnail buttons are fixed-size as in our last example here, but are
positioned at computed coordinates. I’ll defer further details here, though, because
we’ll study that extension in conjunction with canvases in the next chapter. And in
Chapter 11, we’ll apply this technique to an even more full-featured image program
called PyPhoto.
To learn how these programs do their jobs, though, we need to move on to the next
chapter, and the second half of our widget tour.
Viewing and Processing Images with PIL | 505