id int64 0 25.6k | text stringlengths 0 4.59k |
|---|---|
5,200 | def message (self)print('nini!'self method (or could build dialog change me access the 'helloinstance try running rad and editing the messages printed by radactions in another windowyou should see your new messages printed in the stdout console window each time the gui' buttons are pressed this example is deliberately ... |
5,201 | be called directly without subclassdesigned to be mixed in after (further to the right thanapp-specific classeselsesubclass gets methods here (destroyokaytoquit)instead of from app-specific classes--can' redefine ##############################################################################""import osglob from tkinter ... |
5,202 | tk __init__(selfself __app app self configborders(appkindiconfiledef quit(self)if self okaytoquit()threads runningif askyesno(self __app'verify quit program?')self destroy(quit whole app elseshowinfo(self __app'quit not allowed'or in okaytoquitdef destroy(self)tk quit(selfexit app silently redef if exit ops def okaytoq... |
5,203 | other thingsthe classes arrange for automatic quit verification dialog pop ups and icon file searching for instancethe window classes always search the current working directory and the directory containing this module for window icon fileonce per process by using classes that encapsulate--that ishide--such detailswe i... |
5,204 | button(selftext='sing'command=self destroypack(contentsub(non-class usage win popupwindow('popup''attachment'button(wintext='redwood'command=win quitpack(button(wintext='sing 'command=win destroypack(mainloop(if __name__ ='__main__'_selftest(when runthe test generates the window in figure - all generated windows get bl... |
5,205 | in we learned about threads and the queue mechanism that threads typically use to communicate with one another we also described the application of those ideas to guis in the abstract in we specialized some of these topics to the tkinter gui toolkit we're using in this book and expanded on the threaded gui model in gen... |
5,206 | more loosely coupled (though gui can also display data from independent serverswhatever we call itthis model both avoids blocking the gui while tasks run and avoids potentially parallel updates to the gui itself as more concrete examplesuppose your gui needs to display telemetry data sent in real time from satellite ov... |
5,207 | for in range( )time sleep( print('put'dataqueue put('[producer id=%dcount=% ](idi)def consumer(root)tryprint('get'data dataqueue get(block=falseexcept queue emptypass elseroot insert('end''consumer got =% \nstr(data)root see('end'root after( lambdaconsumer(root) times per sec def makethreads()for in range( )_thread sta... |
5,208 | recoding with classes and bound methods example - takes the model one small step further and migrates it to class to allow for future customization and reuse its operationwindowand output are the same as the prior non-object-oriented versionbut the queue is checked more oftenand there are no standard output prints noti... |
5,209 | for in range( )time sleep( self dataqueue put('[producer id=%dcount=% ](idi)def consumer(self)trydata self dataqueue get(block=falseexcept queue emptypass elseself insert('end''consumer got =% \nstr(data)self see('end'self after( self consumer times per sec def makethreads(selfevent)for in range(self threadsperclick)th... |
5,210 | for more on program exits and daemonic threads (and other scary topics!placing callbacks on queues in the prior section' examplesthe data placed on the queue is always string that' sufficient for simple applications where there is just one type of producer if you may have many different kinds of threads producing many ... |
5,211 | queueand the producer threads have been generalized to place success or failure callback on the queue in response to exits and exceptions moreoverthe actions that run in producer threads receive progress status function whichwhen calledsimply adds progress indicator callback to the queue to be dispatched by the main th... |
5,212 | queued callbacks on each timer event may block gui indefinitelybut running only one can take long time or consume cpu for timer events ( progress)assumes callback is either short-lived or updates display as it runsafter callback runthe code here reschedules and returns to event loop and updatesbecause this perpetual lo... |
5,213 | def __init__(self)self count self mutex thread allocate_lock(def incr(self)self mutex acquire(self count + self mutex release(def decr(self)self mutex acquire(self count - self mutex release(def __len__(self)return self count or use threading semaphore or with self mutextrue/false if used as flag ######################... |
5,214 | text scrolledtext(text pack(threadchecker(textstart thread loop in main thread text bind('' need list for maprange ok lambda eventlist(map(oneventrange( ))text mainloop(pop-up windowenter tk event loop this module' comments describe its implementationand its self-test code demonstrates how this interface is used notice... |
5,215 | example - pp \gui\tools\threadtools-test-classes py tests thread callback queuebut uses class bound methods for action and callbacks import time from threadtools import threadcheckerstartthread from tkinter scrolledtext import scrolledtext class myguidef __init__(selfreps= )self reps reps uses default tk root self text... |
5,216 | time sleep( if progressprogress(iif id = raise exception access to object state here progress callbackqueued odd numberedfail thread callbacksdispatched off queue in main thread def threadexit(selfmyname)self text insert('end''% \texit\nmynameself text see('end'def threadfail(selfexc_infomyname)have access to self stat... |
5,217 | restructure it to initialize widgets on startupcall mainloop once to start event processing and display the main windowand move all program logic into callback functions triggered by user actions your original program' actions become event handlersand your original main flow of control becomes program that builds main ... |
5,218 | def __init__(self,parent=none)frame __init__(self,parentself pack(label(selftext ="basic demos"pack(button(selftext='open'command=self openfilepack(fill=bothbutton(selftext='save'command=self savefilepack(fill=bothself open_name self save_name "def openfile(self)save user results self open_name askopenfilename(use dial... |
5,219 | note that this is different from using nested (recursivemainloop calls to implement modal dialogsas we did in in that modethe nested mainloop call returns when the dialog' quit method is calledbut we return to the enclosing mainloop layer and remain in the realm of event-driven programming example - instead runs mainlo... |
5,220 | detect incoming output to be displayed the non-gui script would not be blocked by mainloop call for examplethe gui could be spawned by the non-gui script as separate programwhere user interaction results can be communicated from the spawned gui to the script using pipessocketsfilesor other ipc mechanisms we met in the ... |
5,221 | from socket import port host 'localhostdef redirectout(port=porthost=host)""connect caller' standard output stream to socket for gui to listenstart caller after listener startedelse connect fails before accept ""sock socket(af_inetsock_streamsock connect((hostport)caller operates in client mode file sock makefile(' 'fi... |
5,222 | gui server sideread and display non-gui script' output import sysos from socket import including socket error from tkinter import tk from pp launchmodes import portablelauncher from pp gui tools guistreams import guioutput myport sockobj socket(af_inetsock_streamsockobj bind((''myport)sockobj listen( gui is serverscrip... |
5,223 | notice how we're displaying bytes strings in figure - --even though the non-gui script prints textthe gui script reads it with the raw socket interfaceand sockets deal in binary byte strings in python run this example by yourself for closer look in high-level termsthe gui script spawns the non-gui script and displays p... |
5,224 | non-gui connects to it or the non-gui script will be denied connection and will fail because of the buffered text nature of the socket makefile objects used for streams herethe client program is required to flush its printed output with sys stdout flush to send data to the gui--without this callthe gui receives and dis... |
5,225 | standard streams to be unbufferedso we get printed text immediately as it is producedinstead of waiting for the spawned program to completely finish we talked about this option in when discussing deadlocks and pipes recall that print writes to sys stdoutwhich is normally buffered when connected to pipe this way if we d... |
5,226 | window tk(button(windowtext='go!'command=launchpack(window mainloop(the - unbuffered flag is crucial here again--without ityou won' see the text output window the gui will be blocked in the initial pipe input call indefinitely because the spawned program' standard output will be queued up in an in-memory buffer on the ... |
5,227 | in the terminal windowbecause of such constraintsto avoid blocked statesa separately running gui cannot generally read data directly if its appearance may be delayed for instancein the socketbased scripts of the prior section (example - )the after timer loop allows the gui to poll for data instead of waitingand display... |
5,228 | input shows up on the input pipedef callback(filemask)read from file here import _tkintertkinter _tkinter createfilehandler(filetkinter readablecallbackthe file handler creation call is also available within tkinter and as method of tk instance object unfortunately againas noted near the end of this call is not availab... |
5,229 | elseif not linestop loop at end-of-file output write(termelse display next line return output write(lineroot after( lambdaconsumer(outputrootterm)def redirectedguishellcmd(commandroot)input os popen(command' 'output guioutput(rootthread start_new_thread(producer(input,)consumer(outputrootstart non-gui program start rea... |
5,230 | blocking makes this redirectedguishellcmd much more generally useful than the original pipe version we coded compared to the sockets of the prior sectionthoughthis solution is bit of mixed bagbecause this gui reads the spawned program' standard outputno changes are required in the non-gui program unlike the socket-base... |
5,231 | from tkinter import tk from pipe_gui import redirectedguishellcmd root tk(redirectedguishellcmd('python - spams py'rootfigure - command pipe gui displaying another program' output if the spawned program exitsexample - ' producer thread detects end-of-file on the pipe and puts final empty line in the queuein response th... |
5,232 | the pydemos and pygadgets launchers to close out this let' explore the implementations of the two guis used to run major book examples the following guispydemos and pygadgetsare simply guis for launching other gui programs in factwe've now come to the end of the demo launcher story--both of the new programs here intera... |
5,233 | is set to include the directory containing the pp examples root directory if you wish to run the scripts here directlythey don' attempt to automatically configure your system or module import search paths to make this launcher bar even easier to rundrag it out to your desktop to generate clickable windows shortcut (do ... |
5,234 | description of the last demo spawnedand links pop up containing radio buttons that open local web browser on book-related sites when pressedthe info pop up displays simple message line and changes its font every second to draw attention to itselfsince this can be bit distractingthe pop up starts out iconified (click th... |
5,235 | examples aren' gui-basedand so aren' listed here also seepygadgets pya simpler script for starting programs in non-demo mode that you wish to use on regular basis pygadgets_bar pywwhich creates button bar for starting all pygadgets programs on demandnot all at once launcher py for starting programs without environment ... |
5,236 | stat popupwindow('pp demo info'stat protocol('wm_delete_window'lambda: ignore wm delete info label(stattext 'select demo'font=('courier' 'italic')padx= pady= bg='lightblue'info pack(expand=yesfill=both###############################################################################add launcher buttons with callback objec... |
5,237 | what='image slideshowplus note editor'doit='gui/slideshow/slideshowplus py gui/gifs'code=['gui/texteditor/texteditor py''gui/slideshow/slideshow py''gui/slideshow/slideshowplus py']code omittedsee examples package ###############################################################################toggle info message box fon... |
5,238 | because of its different rolepygadgets takes more data-driven approach to building the guiit stores program names in list and steps through it as needed instead of using sequence of precoded demobutton calls the set of buttons on the launcher bar gui in figure - for exampledepends entirely upon the contents of the prog... |
5,239 | portablelauncher(namecommandline)(print('one moment please 'if sys platform[: ='win'for in range( )time sleep( )print( ( + )call now to start now windowskeep console secs def runlauncher(mytools)""pop up simple launcher bar for later use ""root mainwindow('pygadgets pp 'or root tk(if prefer for (namecommandlinein mytoo... |
5,240 | on demand on many platformsyou can drag this out as shortcut on your desktop for easy access this way you can also run script like this at your system' startup to make it always available (and to save mouse clickfor instanceon windowssuch script might be automatically started by adding it to your startup folderand on u... |
5,241 | complete gui programs "pythonopen sourceand camarosthis concludes our look at building guis with python and its standard tkinter libraryby presenting collection of realistic gui programs in the preceding four we met all the basics of tkinter programming we toured the core set of widgets--python classes that generate de... |
5,242 | of python programs that really use for instancethe text editor and clock guis that we'll meet here are day-to-day workhorses on my machines because they are written in python and tkinterthey work unchanged on my windows and linux machinesand they should work on macs too since these are pure python scriptstheir future e... |
5,243 | software complexity and dependencies especially for highly interactive and nontrivial interfacesthoughstandalone/desktop tkinter guis can be an indispensable feature of almost any python program you write the programs in this underscore just how far python and tkinter can take you this strategy as for all case-study in... |
5,244 | of us who remember time when it was completely normal for car owners to work on and repair their own automobiles still fondly remember huddling with friends under the hood of camaro in my youthtweaking and customizing its engine with little workwe could make it as fastflashyand loud as we liked moreovera breakdown in o... |
5,245 | most of the examples in this book pyedit supports all the usual mouse and keyboard text-editing operationscut and pastesearch and replaceopen and saveundo and redoand so on but reallypyedit is bit more than just another text editor--it is designed to be used as both program and library componentand it can be run in var... |
5,246 | window' default appearance running in windows after opening pyedit' own source code file the main part of this window is text widget objectand if you read ' coverage of this widgetpyedit text-editing operations will be familiar it uses text markstagsand indexesand it implements cut-and-paste operations with the system ... |
5,247 | pyedit pops up variety of modal and nonmodal dialogsboth standard and custom figure - shows the custom and nonmodal changefontand grep dialogsalong with standard dialog used to display file statistics (the final line count may varyas tend to tweak code and comments right up until final draftfigure - pyedit with colorsa... |
5,248 | you need bit more to handle multiple-line statements and expression result displaysread and run python statement stringslike pyedit' run code menu option namespace {while truetryline input('single-line statements only except eoferrorbreak elseexec(linenamespaceor eval(and print result depending on the user' preferencep... |
5,249 | matches listand new pyedit window positioned at match after double-click in the list box another pop up appears while grep search is in progressbut the gui remains fully activein factyou can launch new greps while others are in progress notice how the grep dialog also allows input of unicode encodingused to decode file... |
5,250 | pyedit generates additional pop-up windows--including transient goto and find dialogscolor selection dialogsdialogs that appear to collect arguments and modes for run codeand dialogs that prompt for entry of unicode encoding names on file open and save if pyedit is configured to ask (more on this aheadin the interest o... |
5,251 | entered encoding name to display properly in pyedit (and won' display correctly at all in notepadafter enter the encoding name for the selected file ("koi -rfor the file selected to openin the input dialog of figure - pyedit decodes and pops up the text in its display figure - show the scene after this file has been op... |
5,252 | other pyedit examples and screenshots in this book for other screenshots showing pyedit in actionsee the coverage of the following client programspydemos in deploys pyedit pop-ups to show source-code files pyview later in this embeds pyedit to display image note files pymailgui in uses pyedit to display email texttext ... |
5,253 | begin with the previous version' additions in the third editionpyedit was enhanced witha simple font specification dialog unlimited undo and redo of editing operations file modified tests whenever content might be erased or changed user configurations module here are some quick notes about these extensions font dialog ... |
5,254 | needs pyedit changes in version (fourth editionbesides the updates described in the prior sectionthe following additional enhancements were made for this current fourth edition of this bookpyedit has been ported to run under python and its tkinter library the nonmodal change and font dialogs were fixed to work better i... |
5,255 | could instead allow just one of each dialog to be openbut that' less functional cross-process change tests on quit though not quite as grievouspyedit also used to ignore changes in other open edit windows on quit in main windows as policyon quit in the guipop-up edit windows destroy themselves onlybut main edit windows... |
5,256 | own threadtimer loopand queue there may be multiple threads and loops runningand there may be other unrelated threadsqueuesand timer loops in the process for instancean attached pyedit component in ' pymailgui program can run grep threads and loops of its ownwhile pymailgui runs its own email-related threads and queue ... |
5,257 | or opening files in binary modesince grep might not be able to interpret some of the files it visits as text at allit takes the former approach reallyopening even text files in binary mode to read raw byte strings in mimics the behavior of text files in xand underscores why forcing programs to deal with unicode is some... |
5,258 | code accuratepyedit now strips off any directory path prefix in the file' name before launching itbecause its original directory path may no longer be valid if it is relative instead of absolute for instancepaths of files opened manually are absolutebut file paths in pydemos' code pop ups are all relative to the exampl... |
5,259 | formats when read and encoded to them when written unless text is always stored in files using the platform' default encodingwe need to know which encoding to useboth to load and to save to make this workpyedit uses the approaches described in detail in which we won' repeat in full here in briefthoughtkinter' text widg... |
5,260 | other options are selected in configuration module assignments since it' impossible to predict all possible use case scenariospyedit takes liberal approachit supports all conceivable modesand allows the way it obtains file encodings to be heavily tailored by users in the package' own textconfig module it attempts one e... |
5,261 | vice-versa perhaps we also should always ask the user for an encoding as last resortirrespective of configuration settings for saveswe could also try to guess an encoding to apply to the str content ( try utf- latin- and other common types)but our guess may not be what the user has in mind it' likely that users will wi... |
5,262 | open uses passed-in encodingif anyor else prompts for an encoding name first save reuses known encoding if it has oneand otherwise prompts for new file saves save as always prompts for an encoding name first for the new file grep allows an encoding to be input in its dialog to apply to the full tree searched on the oth... |
5,263 | (pun nearly accidentalin other wordswon' help--it doesn' support the goal of verifying saves on window closesand it doesn' address the issue of quit and destroy calls run for widgets outside the scope of pyedit window classes because of such complicationspyedit instead relies on checking for changes in each individual ... |
5,264 | with an execfile('texteditor py'call the pyw suffix avoids the dos console streams window pop up when launched by clicking on windows todaypyw files can be both imported and runlike normal py files (they can also be double-clickedand launched by python tools such as os system and os startfile)so we don' really need sep... |
5,265 | font ('courier' 'normal'familysizestyle style'bold italicinitial color bg 'lightcyanfg 'blackdefault=whiteblack colorname or rgb hexstr 'powder blue''# initial size height width tk default lines tk default characters search case-insensitive caseinsens true default= /true (on# unicode encoding behavior and names for fil... |
5,266 | using notepad to view text files from command lines run in arbitrary places and wrote the script in example - to launch pyedit in more general and automated fashion this script disables the dos pop uplike example - when clicked or run via desktop shortcut on windowsbut also takes care to configure the module search pat... |
5,267 | ""###############################################################################pyedit python/tkinter text file editor and component uses the tk text widgetplus guimaker menus and toolbar buttons to implement full-featured text editor that can be run as standalone programand attached as component to other guis also us... |
5,268 | configs textconfig __dict__ exceptconfigs {startup font and colors work if not on the path or bad define in client app directory helptext """pyedit version % april ( january ( october programming python th edition mark lutzfor 'reilly mediainc text editor program and embeddable object componentwritten in python/tkinter... |
5,269 | from textconfig import my dir is on the path opensaskuseropensencodingsavesuseknownencodingsavesaskusersavesencodingelsefrom textconfig import always from this package opensaskuseropensencodingsavesuseknownencodingsavesaskusersavesencodingftypes [('all files''*')('text files'txt')('python files'py')for file open dialog... |
5,270 | ('edit' [('undo' self onundo)('redo' self onredo)'separator'('cut' self oncut)('copy' self oncopy)('paste' self onpaste)'separator'('delete' self ondelete)('select all' self onselectall))('search' [('goto ' self ongoto)('find ' self onfind)('refind' self onrefind)('change ' self onchange)('grep ' self ongrep))('tools' ... |
5,271 | hbar config(command=text xviewcall text yview on scroll move or hbar['command']=text xview apply user configs or defaults startfont configs get('font'self fonts[ ]startbg configs get('bg'self colors[ ]['bg']startfg configs get('fg'self colors[ ]['fg']text config(font=startfontbg=startbgfg=startfgif 'heightin configstex... |
5,272 | if not filereturn if not os path isfile(file)showerror('pyedit''could not open file filereturn try known encoding if passed and accurate ( emailtext none empty file 'falsetest for noneif loadencodetrytext open(file' 'encoding=loadencoderead(self knownencoding loadencode except (unicodeerrorlookuperrorioerror)lookupbad ... |
5,273 | showerror('pyedit''could not decode and open file fileelseself setalltext(textself setfilename(fileself text edit_reset( clear undo/redo stks self text edit_modified( clear modified flag def onsave(self)self onsaveas(self currfilemay be none def onsaveas(selfforcefile=none)"" total rewrite for unicode supporttext conte... |
5,274 | if not encpick and self savesaskuserself update(else dialog doesn' appear in rare cases askuser askstring('pyedit''enter unicode encoding for save'initialvalue=(self knownencoding or self savesencoding or sys getdefaultencoding(or '')if askusertrytext encode(askuserencpick askuser except (unicodeerrorlookuperror)lookup... |
5,275 | self text edit_reset(self text edit_modified( self knownencoding none clear undo/redo stks clear modified flag unicode type unknown def onquit(self)""on quit menu/toolbar select and wm border button in toplevel windows don' exit app if others changed don' ask if self unchangedmoved to the top-level window classes at th... |
5,276 | if not self text tag_ranges(sel)showerror('pyedit''no text selected'elseself oncopy(save and delete selected text self ondelete(def onpaste(self)trytext self selection_get(selection='clipboard'except tclerrorshowerror('pyedit''nothing to paste'return self text insert(inserttextadd at current insert cursor self text tag... |
5,277 | self text tag_remove(sel' 'endself text tag_add(selwherepastkeyself text mark_set(insertpastkeyself text see(whereindex past key remove any sel select key for next find scroll display def onrefind(self)self onfind(self lastfinddef onchange(self)""non-modal find/change dialog pass per-dialog inputs to callbacksmay be ch... |
5,278 | text defaultand skip files that fail to decodein worst casesusers may need to run grep times if encodings might existelse opens may raise exceptionsand opening in binary mode might fail to match encoded text against search stringtbdbetter to issue an error if any file fails to decodebut utf- -bytes/char format created ... |
5,279 | footnote issue fnmatch always converts bytes per latin- ""from pp tools find import find matches [tryfor filepath in find(pattern=filenamepattstartdir=dirname)trytextfile open(filepathencoding=encodingfor (linenumlinestrin enumerate(textfile)if grepkey in linestrmsg '% @% [% ](filepathlinenum linestrmatches append(msge... |
5,280 | editor ongoto(int(line)editor text focus_force(noreally new non-modal widnow popup tk(popup title('pyedit grep matches% (% )(grepkeyencoding)scrolledfilenames(parent=popupoptions=matches###########################################################################tools menu commands #######################################... |
5,281 | inherits quit and other behavior of the window that it clones subclass must redefine/replace this if makes its own popupelse this creates bogus extra window here which will be empty""if not makewindownew none assume class makes its own window elsenew toplevel( new edit window in same process myclass self __class__ inst... |
5,282 | run startargs if cmdargs else start run(thecmdthecmd)(elsefork(thecmdthecmd)(os chdir(mycwdspawn in parallel support args or always spawn spawn in parallel go back to my dir def onpickfont(self)"" non-modal font spec dialog pass per-dialog inputs to callbackmay be font dialog open ""from pp gui shellgui formrows import... |
5,283 | self filelabel config(text=str(name)def setknownencoding(selfencoding='utf- ') for saves if inserted self knownencoding encoding else saves use configaskdef setbg(selfcolor)self text config(bg=colordef setfg(selfcolor)self text config(fg=colordef setfont(selffont)self text config(font=fontdef setheight(selflines)self t... |
5,284 | when text editor owns the window ##################################class texteditormain(texteditorguimakerwindowmenu)""main pyedit windows that quit(to exit app on quit in guiand build menu on windowparent may be default tkexplicit tkor toplevelparent must be windowand probably should be tk so this isn' silently destro... |
5,285 | use main window menus texteditor __init__(selfloadfirstloadencodea frame in new popup assert self master =self popup self popup title('pyedit version wintitleself popup iconname('pyedit'self popup protocol('wm_delete_window'self onquittexteditor editwindows append(selfdef onquit(self)close not self text_edit_modified(i... |
5,286 | def start(self)texteditor start(selffor in range(len(self toolbar))if self toolbar[ ][ ='quit'del self toolbar[ibreak if self deletefilefor in range(len(self menubar))if self menubar[ ][ ='file'del self menubar[ibreak elsefor (namekeyitemsin self menubarif name ='file'items append([ , , , , ]guimaker start call delete ... |
5,287 | scrollable canvas when thumbnail is selectedthe corresponding image is displayed full size in pop-up window unlike our prior viewersthoughpyphoto is clever enough to scroll (rather than cropimages too large for the physical display moreoverpyphoto introduces the notion of image resizing--it supports mouse and keyboard ... |
5,288 | or displaying simple one-button window that allows you to select directories to open on demandwhen no initial directory is given or present (see the code' __main__ logicpyphoto also lets you open additional folders in new thumbnail windowsby pressing the key on your keyboard in either thumbnail or an image window figur... |
5,289 | for exampleclicking the left and right mouse buttons will resize the image to the display' height and width dimensionsrespectivelyand pressing the and keys will zoom the image in and out in percent increments both resizing schemes allow you to shrink an image too large to see all at onceas well as expand small photos t... |
5,290 | canvas' scrollable (fullsize is the image sizeand the viewable area size is the minimum of the physical screen size or the size of the image itself the physical screen size is available from the maxsize(method of toplevel windows the net effect is that selected images may be scrolled nowtoowhich comes in handy if they ... |
5,291 | pyphoto is implemented as the single file of example - though it gets some utility for free by reusing the thumbnail generation function of the viewer_thumbs module that we originally wrote near the end of in example - to spare you from having to flip back and forth too muchhere' copy of the code of the thumbs function... |
5,292 | imgobj image open(imgpathmake new thumb imgobj thumbnail(sizeimage antialiasbest downsize filter imgobj save(thumbpathtype via ext or passed thumbs append((imgfileimgobj)exceptnot always ioerror print("skipping"imgpathreturn thumbs some of this example' thumbnail selection window code is also very similar to our earlie... |
5,293 | ""###########################################################################pyphoto thumbnail image viewer with resizing and saves supports multiple image directory thumb windows the initial img dir is passed in as cmd arguses "imagesdefaultor is selected via main window buttonlater directories are opened by pressing ... |
5,294 | hbar scrollbar(containerorient='horizontal'vbar pack(side=rightfill=yhbar pack(side=bottomfill=xself pack(side=topfill=bothexpand=yespack canvas after bars so clipped first vbar config(command=self yviewhbar config(command=self xviewself config(yscrollcommand=vbar setself config(xscrollcommand=hbar setcall on scroll mo... |
5,295 | self state('normal'elif sys platform[: ='win'self state('zoomed'self saveimage imgpil self savephoto imgtk trace((scrwidescrhigh)imgpil sizetoo big for displaynowin size per img do windows fullscreen others use geometry(keep reference on me def sizetodisplayside(selfscaler)resize to fill one side of the display imgpil ... |
5,296 | 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... |
5,297 | canvas create_window(colposrowposanchor=nwwindow=linkwidth=linksizeheight=linksizecolpos +linksize savephotos append(photorowpos +linksize win bind(''ondirectoryopenwin savephotos savephotos return win if __name__ ='__main__'""open dir default or cmdline arg else show simple window to select ""imgdir 'imagesif len(sys ... |
5,298 | pyview window' default display on windows created by running the slideshowplus py script we'll see in example - ahead though it' not obvious as rendered in this bookthe black-on-red label at the top gives the pathname of the photo file displayed for good timemove the slider at the bottom all the way over to " to specif... |
5,299 | and change the note file associated with the currently displayed photo this additional set of widgets should look familiar--the pyedit text editor from earlier in this is attached to pyview in variety of selectable modes to serve as display and editing widget for photo notes figure - shows pyview with the attached pyed... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.