example - pp \gui\pil\viewer-thumbs-fixed py ""use fixed size for thumbnailsso align regularlysize taken from image objectassume all same maxthis is essentially what file selection guis do""import sysmath from tkinter import from pil imagetk import photoimage from viewer_thumbs import makethumbsviewone def viewer(imgdirkind=toplevelcols=none)""custom version that lays out with fixed-size buttons ""win kind(win title('viewerimgdirthumbs makethumbs(imgdirif not colscols int(math ceil(math sqrt(len(thumbs)))savephotos [while thumbsthumbsrowthumbs thumbs[:cols]thumbs[cols:row frame(winrow pack(fill=bothfor (imgfileimgobjin thumbsrowsize max(imgobj sizephoto photoimage(imgobjlink button(rowimage=photofixed or widthheight viewing and processing images with pil