self saveimage save(filenamedef ondirectoryopen(event)""open new image directory in new pop up available in both thumb and img windows ""dirname opendialog show(if dirnameviewthumbs(dirnamekind=topleveldef viewthumbs(imgdirkind=toplevelnumcols=noneheight= width= )""make main or pop-up thumbnail buttons windowuses fixed-size buttonsscrollable canvassets scrollable (fullsizeand places thumbs at abs , coordinates in canvasno longer assumes all thumbs are same sizegets max of all ( , )some may be smaller""win kind(helptxt '(press to open other)win title(appname imgdir helptxtquit button(wintext='quit'command=win quitbg='beige'quit pack(side=bottomfill=xcanvas scrolledcanvas(wincanvas config(height=heightwidth=widthinit viewable window size changes if user resizes thumbs makethumbs(imgdir[(imgfileimgobj)numthumbs len(thumbsif not numcolsnumcols int(math ceil(math sqrt(numthumbs))fixed or numrows int(math ceil(numthumbs numcols) true div max |hthumb=(nameobj)thumb size=(widthheightlinksize max(max(thumb[ sizefor thumb in thumbstrace(linksizefullsize ( upper left , (linksize numcols)(linksize numrowslower right , canvas config(scrollregion=fullsizescrollable area size rowpos savephotos [while thumbsthumbsrowthumbs thumbs[:numcols]thumbs[numcols:colpos for (imgfileimgobjin thumbsrowphoto photoimage(imgobjlink button(canvasimage=photodef handler(savefile=imgfile)viewone(imgdirsavefilelink config(command=handlerwidth=linksizeheight=linksize complete gui programs