imgobj = Image.open(imgpath) # make new thumb
imgobj.thumbnail(size, Image.ANTIALIAS) # best downsize filter
imgobj.save(thumbpath) # type via ext or passed
thumbs.append((imgfile, imgobj))
except: # not always IOError
print("Skipping: ", imgpath)
return thumbs
Some of this example’s thumbnail selection window code is also very similar to our
earlier limited scrolled-thumbnails example in Chapter 9, but it is repeated in this file
instead of imported, to allow for future evolution (Chapter 9’s functional subset is now
officially demoted to prototype).
As you study this file, pay particular attention to the way it factors code into reused
functions and methods, to avoid redundancy; if we ever need to change the way zoom-
ing works, for example, we have just one method to change, not two. Also notice its
ScrolledCanvas class—a reusable component that handles the work of linking scroll
bars and canvases.
Figure 11-11. PyPhoto Save As dialog (the S key; include an extension)
722 | Chapter 11: Complete GUI Programs