at the end of we looked at collection of scripts that display thumbnail image links for all photos in directory therewe noted that scrolling is major requirement for large photo collections now that we know about canvases and scrollbarswe can finally put them to work to implement this much-needed extensionand conclude the image viewer story we began in (wellalmostexample - is mutation of the last codewhich displays thumbnails in scrollable canvas see the prior for more details on its operationincluding the imagetk module imported from the required python imaging library (pilthirdparty extension (needed for thumbnails and jpeg imagesin factto fully understand example - you must also refer to example - since we're reusing that module' thumbnail creator and photo viewer tools herewe are just adding canvaspositioning the fixed-size thumbnail buttons at absolute coordinates in the canvasand computing the scrollable size using concepts outlined in the prior section both horizontal and vertical scrollbars allow us to move through the canvas of image buttons freelyregardless of how many there may be example - pp \gui\pil\viewer_thumbs_scrolled py ""image viewer extensionuses fixed-size thumbnail buttons for uniform layoutand adds scrolling for large image sets by displaying thumbs in canvas widget with scroll barsrequires pil to view image formats such as jpegand reuses thumbs maker and single photo viewer in viewer_thumbs pycaveat/to dothis could also scroll popped-up images that are too large for the screenand are cropped on windows as issee pyphoto later in for much more complete version""import sysmath from tkinter import from pil imagetk import photoimage from viewer_thumbs import makethumbsviewone def viewer(imgdirkind=toplevelnumcols=noneheight= width= )""use fixed-size buttonsscrollable canvassets scrollable (fullsizeand places thumbs at absolute , coordinates in canvascaveatassumes all thumbs are same size ""win kind(win title('simple viewerimgdirquit button(wintext='quit'command=win quitbg='beige'quit pack(side=bottomfill=xcanvas canvas(winborderwidth= vbar scrollbar(winhbar scrollbar(winorient='horizontal'vbar pack(side=rightfill=ypack canvas after bars canvas