handler = lambda savefile=imgfile: ViewOne(imgdir, savefile)
link.config(command=handler, width=size, height=size)
link.pack(side=LEFT, expand=YES)
savephotos.append(photo)
Button(win, text='Quit', command=win.quit, bg='beige').pack(fill=X)
return win, savephotos
if name == 'main':
imgdir = (len(sys.argv) > 1 and sys.argv[1]) or 'images'
main, save = viewer(imgdir, kind=Tk)
main.mainloop()
Figure 8-48 shows the results of applying a fixed size to our buttons; all are the same
size now, using a size taken from the images themselves. The effect is to display all
thumbnails as same-size tiles regardless of their shape, so they are easier to view. Nat-
urally, other layout schemes are possible as well; experiment with some of the config-
uration options in this code on your own to see their effect on the display.
Figure 8-48. Fixed-size thumbnail selection GUI, row frames
Scrolling and canvases (ahead)
The thumbnail viewer scripts presented in this section work well for reasonably sized
image directories, and you can use smaller thumbnail size settings for larger image
collections. Perhaps the biggest limitation of these programs, though, is that the
thumbnail windows they create will become too large to handle (or display at all) if the
image directory contains very many files.
504 | Chapter 8: A tkinter Tour, Part 1