id int64 0 25.6k | text stringlengths 0 4.59k |
|---|---|
4,900 | ""import ossysfind heregets tools find count for filename in find find('pyc'sys argv[ ])count + print(filenameos remove(filenameprint('removed % pyc filescountwhen runall bytecode files in the tree rooted at the passed-in directory name are removed as beforethis timethoughour script works just about everywhere python d... |
4,901 | ""import ossys listonly false textexts [py'pyw'txt' ' 'ignore binary files def searcher(startdirsearchkey)global fcountvcount fcount vcount for (thisdirdirsherefilesherein os walk(startdir)for fname in filesheredo non-dir files here fpath os path join(thisdirfnamefnames have no dirpath visitfile(fpathsearchkeydef visit... |
4,902 | =\preview\attachgui py =\preview\bob pkl skipping \preview\bob pkl more lines omittedpauses for enter key press at matches found in filesvisited the script lists each file it checks as it goestells you which files it is skipping (names that end in extensions not listed in the variable textexts that imply binary data)an... |
4,903 | laziness is the mother of many framework armed with the portable search_all script from example - was able to better pinpoint files to be edited every time changed the book examples tree content or structure at least initiallyin one window ran search_all to pick out suspicious files and edited each along the way by han... |
4,904 | just wraps os walk for easier use and extensionas well as generic searchvisitor class that generalizes the notion of directory searches by itselfsearchvisitor simply does what search_all didbut it also opens up the search process to customization--bits of its behavior can be modified by overloading its methods in subcl... |
4,905 | if self trace print(dirpath'override or extend me def visitfile(selffilepath)called for each file self fcount + override or extend me if self trace print(self fcount'=>'filepathclass searchvisitor(filevisitor)""search files at and below startdir for stringsubclassredefine visitmatchextension listscandidate as neededsub... |
4,906 | visitor filevisitor(trace= visitor run(sys argv[ ]print('visited % files and % dirs(visitor fcountvisitor dcount)if testmask dosearchvisitor searchvisitor(sys argv[ ]trace= visitor run(sys argv[ ]print('found in % filesvisited % (visitor scountvisitor fcount)selftest(int(sys argv[ ]) dolist dosearch this module primari... |
4,907 | searchvisitor (two separate traversals are performedthe first argument is really used as bit mask to select one or more supported self-testsif test' bit is on in the binary value of the argumentthe test will be run because is in binaryit selects both search ( and listing ( in more user-friendly systemwe might want to b... |
4,908 | ""use"python \tools\visitor_edit py string rootdir?add auto-editor startup to searchvisitor in an external subclass componentautomatically pops up an editor on each file containing string as it traversescan also use editor='editor 'notepadon windowsto use texteditor from later in the booktry 'python gui\texteditor\text... |
4,909 | = :\temp\pp \examples\pp \tempparts\part- txt = :\temp\pp \examples\pp \tempparts\part- html edited filesvisited thisfinallyis the exact tool was looking for to simplify global book examples tree maintenance after major changes to things such as shared modules and file and directory namesi run this script on the exampl... |
4,910 | listonly input('list only?'='yvisitor replacevisitor(sys argv[ ]sys argv[ ]listonlyif listonly or input('proceed with changes?'=' 'visitor run(startdir=sys argv[ ]action 'changedif not listonly else 'foundprint('visited % filesvisitor fcountprint(action'% files:len(visitor changed)for fname in visitor changedprint(fnam... |
4,911 | in places you didn' anticipateyou might just ruin an entire tree of files by running the replacevisitor object defined here on the other handif the string is something very specificthis object can obviate the need to manually edit suspicious files for instancewebsite addresses in html files are likely too specific to s... |
4,912 | srcexts [py'pyw'cgi'html' 'cxx' ' 'if __name__ ='__main__'walker sourcelines(walker run(sys argv[ ]print('visited % files and % dirs(walker fcountwalker dcount)print('-'* print('source files=>%dlines=>% (walker srcfileswalker srclines)print('by types:'pprint pprint(walker extsumsprint('\ncheck sums:'end='print(sum( ['l... |
4,913 | example - simply replaces the "fromdirectory path string with the "todirectory path stringat the front of all directory names and pathnames passed in from os walk the results of the string replacements are the paths to which the original files and directories are to be copied example - pp \tools\visitor_cpall py ""use"... |
4,914 | assumptions to keep the code simple the "todirectory is assumed not to exist initiallyand exceptions are not ignored along the way here it is copying the book examples tree from the prior edition again on windowsc:\pp \toolsset pythonpath pythonpath= :\users\mark\stuff\books\ \pp \dev\examples :\pp \toolsrmdir / copyte... |
4,915 | the visitor framework handles walking details automatically the collectorfor instancesimply appends to list as search visitor detects matched files and allows the default list of text filename extensions in the search visitor to be overridden per instance--it' roughly like combination of find and grep on unixfrom visit... |
4,916 | fourth editions of this bookthe original os path walk call was removed in python xand os walk became the only automated way to perform tree walks in the standard library examples from the prior edition that used os path walk were effectively broken by contrastalthough the visitor classes used this calltooits clients di... |
4,917 | helpmsg ""sorrycan' find media player for '%son your systemadd an entry for your system to the media player dictionary for this type of file in playfile pyor play the file manually ""def trace(*args)print(*argswith spaces between #################################################################################player te... |
4,918 | #'win 'winstart(cmdline('start % 'videotools 'linux 'cmdline('tkcvideo_c % ')'win 'winstart()imagetools 'linux 'cmdline('zimager % ')'win 'winstart()texttools 'linux 'cmdline('vi % ')'win 'cmdline('notepad % 'apptools 'win 'winstart(startfile or system zaurus pda avoid dos pop up zaurus pda zaurus pda or try pyeditdocx... |
4,919 | trywebbrowser(filename**optionsgeneral scheme def playfile(filenamemimetable=mimetable**options)""play media file of any typeuses mimetypes to guess media type and map to platform-specific player tablesspawn web browser if text/htmlmedia type unknownor has no table ""contenttypeencoding mimetypes guess_type(filenameif ... |
4,920 | let' explore these briefly before we run the script the python webbrowser module the standard library webbrowser module used by this example provides portable interface for launching web browsers from python scripts it attempts to locate suitable web browser on your local machine to open given url (file or web addressf... |
4,921 | new tab in an existing window under internet explorer this is also why didn' need the "file://full url prefix in the preceding listing technicallyinternet explorer is only run if this is what is registered on your computer for the file type being openedif notthat file type' handler is opened instead some imagesfor exam... |
4,922 | 'htmla subtle thingthe second item in the tuple returned from the mimetypes guess is an encoding type we won' use here for opening purposes we still have to pay attention to itthough--if it is not noneit means the file is compressed (gzip or compress)even if we receive media content type for exampleif the filename is s... |
4,923 | py ('text/ -python'nonepyw (nonenonehtml ('text/html'nonec ('text/plain'noneh ('text/plain'nonexml ('text/xml'nonewe can add this technique to our earlier searchvisitor class by redefining its candidate selection methodin order to replace its default extension lists with mimetypes guesses-yet more evidence of the power... |
4,924 | computer and with your own test files to see what happens as usualyou can also test it interactively (use the package path like this one to import from different directoryassuming your module search path includes the pp root)from pp system media playfile import playfile playfile( ' :\movies\mov mpg'video/mpeg we'll use... |
4,925 | run the original version of this example has now been largely superseded by the standard library' webbrowser modulewhich arose after this example had been developed (reptilian minds think alike!in this editionlaunchbrowser simply parses command-line arguments for backward compatibility and invokes the open function in ... |
4,926 | gui programming this part of the book shows you how to apply python to build portable graphical user interfacesprimarily with python' standard tkinter library the following cover this topic in depth this outlines gui options available to python developersand then presents brief tutorial that illustrates core tkinter co... |
4,927 | graphical user interfaces "here' looking at youkidfor most software systemsa graphical user interface (guihas become an expected part of the package even if the gui acronym is new to youchances are that you are already familiar with such interfaces--the windowsbuttonsand menus that we use to interact with software prog... |
4,928 | related tools most of the interface devices you're accustomed to seeing--slidersmenusdialogsimagesand their kin--show up here these two are not fully complete tkinter reference (which could easily fill large book by itself)but they should be enough to help you get started coding substantial python guis the examples in ... |
4,929 | one other point ' like to make right awaymost guis are dynamic and interactive interfacesand the best can do here is show static screenshots representing selected states in the interactions such programs implement this really won' do justice to most examples if you are not working along with the examples alreadyi encou... |
4,930 | before we start wading into the tkinter pondlet' begin with some perspective on python gui options in general because python has proven to be such good match for gui workthis domain has seen much activity over the years in factalthough tkinter is by most accounts still the most widely used gui toolkit in the python wor... |
4,931 | and as such it meshes well with scripting language like python because of such attributespython' tkinter module ships with python as standard library module and is the basis of python' standard idle integrated development environment gui in facttkinter is the only gui toolkit that is part of pythonall others on this li... |
4,932 | powerful toolkit wxpython comes with richer set of widgets out of the box than tkinterincluding trees and html viewers--things that may require extensions such as pmwtixor ttk in tkinter in additionsome prefer the appearance of the interfaces it renders boaconstructor and wxdesigneramong other optionsprovide gui builde... |
4,933 | also has internet roles we'll meet briefly in ironpython in very similar veinthe ironpython system--an implementation of the python language for the net environment and runtime enginewhichamong other thingscompiles python programs to net bytecode--also offers python scripts gui construction options in the net framework... |
4,934 | java platform for building rias which can run across variety of connected devices pyjamas an ajax-based port of the google web toolkit to pythonwhich comes with set of interface widgets and compiles python code that uses those widgets into javascriptto be run in browser on client the html standard under development pro... |
4,935 | of all the prior section' gui optionsthoughtkinter is by far the de facto standard way to implement portable user interfaces in python todayand the focus of this part of the book the rationale for this approach was explained in in shortwe elected to present one toolkit in satisfying depth instead of many toolkits in le... |
4,936 | using gui toolkittoolet' take quick look at the story tkinter has to tell on these fronts as well tkinter documentation this book explores tkinter fundamentals and most widgets toolsand it should be enough to get started with substantial gui development in python on the other handit is not an exhaustive reference to th... |
4,937 | helpand an interface to the blt graph widget the interface to pmw megawidgets is similar to that of basic tkinter widgetsso python scripts can freely mix pmw megawidgets with standard tkinter widgets moreoverpmw is pure python codeand so requires no compiler or tools to install to view its widgets and the corresponding... |
4,938 | book focuses on tkinter fundamentalsand tix and ttk are both too large to cover in useful fashion here pil the python imaging library (pilis an open source extension package that adds image-processing tools to python among other thingsit provides tools for image thumbnailstransformsand conversionsand it extends the bas... |
4,939 | of tkinter actually stems from the underling tk library it wraps python' tkinter adds software layer on top of tk that allows python scripts to call out to tk to build and configure interfaces and routes control back to python scripts that handle user-generated events ( mouse clicksthat isgui calls are internally route... |
4,940 | on to the codelet' start out by quickly stepping through few small examples that illustrate basic concepts and show the windows they create on the computer display the examples will become progressively more sophisticated as we move alongbut let' get handle on the fundamentals first "hello worldin four lines (or lessth... |
4,941 | the gui script is trivial examplebut it illustrates steps common to most tkinter programs this python code does the following loads widget class from the tkinter module makes an instance of the imported label class packs (arrangesthe new label in its parent widget calls mainloop to bring up the window and start the tki... |
4,942 | when widgets are constructed in tkinterwe can specify how they should be configured the gui script passes two arguments to the label class constructorthe first is parent-widget objectwhich we want the new label to be attached to herenone means "attach the new label to the default top-level window of this program laterw... |
4,943 | like all python codethe module in example - can be started in number of ways-by running it as top-level program filec:\pp \gui\intropython gui py by importing it from python session or another module fileimport gui by running it as unix executable if we add the special #line at the topgui py and in any other way python... |
4,944 | pythonw exe executablenot python exe (in factpyw files are simply registered to be opened by pythonwon linuxthe pyw doesn' hurtbut it isn' necessarythere is no notion of streams pop up on unix-like machines on the other handif your gui scripts might run on windows in the futureadding an extra "wat the end of their name... |
4,945 | to both their packing order and their side attachment options when widgets are griddedthey are assigned row and column numbers instead none of this will become very meaningfulthoughuntil we have more than one widget in windowso let' move on notice that this version calls the pack method right away after creating the la... |
4,946 | example - pp \gui\intro\gui py--expansion from tkinter import label(text='hello gui world!'pack(expand=yesfill=bothmainloop(when widgets are packedwe can specify whether widget should expand to take up all available spaceand if sohow it should stretch to fill that space by defaultwidgets are not expanded when their par... |
4,947 | asks the packer to expand the allocated space for the widget in general into any unclaimed space in the widget' parent fill option can be used to stretch the widget to occupy all of its allocated space combinations of these two options produce different layout and resizing effectssome of which become meaningful only wh... |
4,948 | from tkinter import root tk(widget label(rootwidget config(text='hello gui world!'widget pack(side=topexpand=yesfill=bothroot title('gui py'root mainloop(the config method (which can also be called by its synonymconfigurecan be called at any time after construction to change the appearance of widget on the fly for inst... |
4,949 | relies on an old coding style that was widely used until python which passed configuration options in dictionary instead of keyword arguments in this schemepacker options can be sent as values of the key pack ( class in the tkinter modulethe dictionary call scheme still works and you may see it in old python codebut it... |
4,950 | by python immediately after running its pack method howeverbecause tkinter emits tk calls when objects are constructedthe label will be drawn on the display as expectedeven though we haven' held onto the corresponding python object in our script in facttkinter internally cross-links widget objects into long-lived tree ... |
4,951 | data is discarded if the python image object is garbage collected tkinter variable class objects also temporarily unset an associated tk variable if reclaimedbut this is uncommon and less harmful adding buttons and callbacks so farwe've learned how to display messages in labelsand we've met tkinter core concepts along ... |
4,952 | closes all windowsbut its relative destroy erases just one window example - pp \gui\intro\gui py from tkinter import root tk(button(roottext='press'command=root quitpack(side=leftroot mainloop(this version produces the window in figure - because we didn' tell the button to expand into all available spaceit does not do ... |
4,953 | this makes the button fill the whole window initially (its allocation is expandedand it is stretched to fill that allocationit also makes the button grow as the parent window is resized as shown in figure - the button in this window does expand when its parent expandsbut only along the horizontal axis figure - resizing... |
4,954 | contained by are set to expand too herethe button' only parent is the tk root window of the programso parent expandability isn' yet an issuein later exampleswe'll need to make enclosing frame widgets expandable too we will revisit the packer geometry manager when we meet multiple-widget displays that use such devices l... |
4,955 | helloi must be going :\pp \gui\intronormallysuch messages would be displayed in the guibut we haven' gotten far enough to know how just yet callback functions usually do moreof course (and may even pop up new independent windows altogether)but this example illustrates the basics in generalcallback handlers can be any c... |
4,956 | more typicallylambdas are used to provide an indirection layer that passes along extra data to callback handler ( omit pack and mainloop calls in the following snippets for simplicity)def handler(ab)use and would normally be called with no args button(text='ni'command=(lambdahandler( 'spam'))lambda adds arguments altho... |
4,957 | okwrap in lambda to defer is always equivalent to the longerand to some observers less convenientdoublefunction formdef handler(name)print(namedef temp()handler('spam'button(command=tempokrefence but do not call we need only the zero-argument lambda or the zero-argument callable referencethoughnot both--it makes no sen... |
4,958 | lambda here entirelywe could register the handler itself and cut out the middleman although simple in this trivial examplearguments are generally preferred to globalsbecause they make external dependencies more explicitand so make code easier to understand and change in factthe same handler might be usable in other con... |
4,959 | function later with no argumentsall its defaults are used this was not an issue in the original version of this example because name lived in the global scopeand the code of the lambda will find it there when it is run when nested within functionthoughx may have disappeared after the enclosing function exits passing in... |
4,960 | wellalmost there is catch it turns out that within lambda (or def)references to names in the enclosing scope are actually resolved when the generated function is callednot when it is created because of thiswhen the function is later calledsuch name references will reflect the latest or final assignments made to the nam... |
4,961 | def action()return spam spam 'nireturn action act normal(print(act()reallylooked up when used also prints 'nias this impliesthe enclosing scope name isn' resolved when the nested function is made--in factthe name hasn' even been assigned yet in this example the name is resolved when the nested function is called the sa... |
4,962 | created within the loops if you're going to make functions within loopyou have to apply the last example' behavior to the loop variabledef odd()funcs [for in 'abcdefg'funcs append((lambdac)return funcs will be looked up later does not remember current for func in odd()print(func()end='oopsprint 'snot , ,cherethe func l... |
4,963 | generally reference enclosing scope loop variables within nested functionfor examplebecause they will change as the loop progresses in most other casesthoughenclosing scope variables will take on only one value in their scope and so can be used freely we'll see this phenomenon at work in later examples that construct l... |
4,964 | remember information for use on events--simply assign the information to self instance attributesclass someguiclassdef __init__(self)self self 'spambutton(text='hi'command=self handlerdef handler(self)use self xself because the event will be dispatched to this class' method with reference to the original instance objec... |
4,965 | helloi must be going :\pp \gui\intropython gui py hello lambda world :\pp \gui\intropython gui py hello class method world :\pp \gui\intropython gui py hello __call__ world there are good reasons for each callback coding scheme (functionlambdaclass methodcallable class)but we need to move on to larger examples in order... |
4,966 | finallytkinter scripts can also register callback handlers to be run in special contextssuch as timer expirationsinput data arrivaland event-loop idle states scripts can also pause for state-change events related to windows and special variables we'll meet these event interfaces in more detail near the end of binding e... |
4,967 | detail later in this book firstthoughlet' focus on building guis that are larger than single button and explore few other ways to use classes in gui work adding multiple widgets it' time to start building user interfaces with more than one widget example - makes the window shown in figure - example - pp \gui\intro\gui ... |
4,968 | hello stdout worldthe notion of attaching widgets to containers turns out to be at the core of layouts in tkinter before we go into more detail on that topicthoughlet' get small widget resizing revisitedclipping earlierwe saw how to make widgets expand along with their parent windowby passing expand and fill options to... |
4,969 | scroll ( textlistsso that the scroll bars remain as the window shrinks attaching widgets to frames in larger termsthe critical innovation in this example is its use of framesframe widgets are just containers for other widgetsand so give rise to the notion of guis as widget hierarchiesor trees herewin serves as an enclo... |
4,970 | button(wintext='hello'command=greetingpack(side=leftlabel(wintext='hello container world'pack(side=topbutton(wintext='quit'command=win quitpack(side=rightyou will wind up with the very different display shown in figure - even though you've moved the label code only one line down in the source file (contrast with figure... |
4,971 | to make all of these grow along with their windowthoughwe also need to make the container frame expandablewidgets expand beyond their initial packer arrangement only if all of their parents expandtoo here are the changes in gui pywin frame(win pack(side=topexpand=yesfill=bothbutton(wintext='hello'command=greetingpack(s... |
4,972 | side they were givenunless they are positioned with anchor or stretched with fill to demonstratechange gui to use this sort of codebutton(wintext='hello'command=greetingpack(side=leftanchor=nlabel(wintext='hello container world'pack(side=topbutton(wintext='quit'command=win quitpack(side=rightthe only thing new here is ... |
4,973 | example - builds the window in figure - example - pp \gui\intro\gui py from tkinter import class hellobutton(button)def __init__(selfparent=none**config)button __init__(selfparent**configself pack(self config(command=self callbackdef callback(self)print('goodbye world 'self quit(add callback method and pack myself coul... |
4,974 | example - standardizes behavior--it allows widgets to be configured by subclassing instead of by passing in options in factits hellobutton is true buttonwe can pass in configuration options such as its text as usual when one is made but we can also specify callback handlers by overriding the callback method in subclass... |
4,975 | for complete versionand watch for more on its widget configuration options in but it illustrates the application of common appearance by subclassing widgets directly--every button created from its class looks the sameand will pick up any future changes in its configurations automatically widget subclasses are programme... |
4,976 | figure - example - pp \gui\intro\gui py from tkinter import class hello(frame)def __init__(selfparent=none)frame __init__(selfparentself pack(self data self make_widgets(an extended frame do superclass init attach widgets to self def make_widgets(self)widget button(selftext='hello frame world!'command=self messagewidge... |
4,977 | can make for brittle code when building up larger gui structures but by subclassing frame as we've done herethe class becomes an enclosing context for the guiwidgets are added by attaching objects to selfan instance of frame container subclass ( buttoncallback handlers are registered as bound methods of selfand so are ... |
4,978 | this script just adds hello' button to the right side of parent-- container frame in factthe button on the right in this window represents an embedded componentits button really represents an attached python class object pressing the embedded class' button on the right prints message as beforepressing the new button ex... |
4,979 | attach an already coded and fully debugged calculator objectyou'll begin to better understand the power of this paradigm if we code all of our gui components as classesthey automatically become library of reusable widgetswhich we can combine in other applications as often as we like extending class components when guis... |
4,980 | the original to add new button and change message' behavior although this example is simpleit demonstrates technique that can be powerful in practiceto change gui' behaviorwe can write new class that customizes its parts rather than changing the existing gui code in place the main code need be debugged only once and ca... |
4,981 | the guimuch as beforec:\pp \gui\intropython gui py hello number hello number hello number hello number also as beforeself data retains state between eventsand callbacks are routed to the self message method within this class unlike beforethe hellopackage class is not itself kind of frame widget in factit' not kind of a... |
4,982 | frm mainloop(fails!--need part top pack(side=rightthis won' quite workbecause part isn' really widget to treat it as suchyou must descend to part top before making gui configurations and hope that the name top is never changed by the class' developer in other wordsit exposes some of the class' internals the class could... |
4,983 | table - tkinter widget classes widget class description label simple message area button simple labeled push-button widget frame container for attaching and arranging other widget objects topleveltk new window managed by the window manager message multiline label entry simple single-line text-entry field checkbutton tw... |
4,984 | widget afterwaitand update methods other tools standard dialogsclipboardbind and eventwidget configuration optionscustom and modal dialogsanimation techniques most tkinter widgets are familiar user interface devices some are remarkably rich in functionality for instancethe text class implements sophisticated multiline ... |
4,985 | variables associated with widgets are tkinter class objects with methods in pythonwidget creation commands ( buttonare python class names that start with an uppercase letter ( button)two-word widget operations ( add commandbecome single method name with an underscore ( add_command)and the "configuremethod can be abbrev... |
4,986 | tkinter tourpart "widgets and gadgets and guisoh my!this is continuation of our look at gui programming in python the previous used simple widgets--buttonslabelsand the like--to demonstrate the fundamentals of python/tkinter coding that was simple by designit' easier to grasp the big gui picture if widget interface det... |
4,987 | widget and window configuration options dialogsboth standard and custom low-level event binding tkinter linked variable objects using the python imaging library (pilextension for other image types and operations after this concludes the two-part tour by presenting the remainder of the tkinter library' tool setmenustext... |
4,988 | backgroundand with font that' very different from what we've seen so far in factthis script customizes the label in number of wayscolor by setting the bg option of the label widget hereits background is displayed in blackthe fg option similarly changes the foreground (textcolor of the widget to yellow these color optio... |
4,989 | finallythe label is made generally expandable and stretched by setting the pack expand and fill options we met in the last the label grows as the window does if you maximize this windowits black background fills the whole screen and the yellow message is centered in the middletry it in this scriptthe net effect of all ... |
4,990 | to see the effects generated by these two scriptssettingstry out few changes on your computer most widgets can be given custom appearance in the same wayand we'll see such options used repeatedly in this text we'll also meet operational configurationssuch as focus (for focusing inputand others in factwidgets can have d... |
4,991 | import sys from tkinter import toplevelbuttonlabel win toplevel(win toplevel(two independent windows but part of same process button(win text='spam'command=sys exitpack(button(win text='spam'command=sys exitpack(label(text='popups'pack(win mainloop(on default tk(root window the toplevel script gets root window by defau... |
4,992 | toplevel is roughly like frame that is split off into its own window and has additional methods that allow you to deal with top-level window properties the tk widget is roughly like toplevelbut it is used to represent the application root window toplevel windows have parentsbut tk windows do not--they are the true root... |
4,993 | windowinstead of sys exit to shut down the entire programto see how this method really does its worklet' move on to window protocols top-level window protocols both tk and toplevel widgets export extra methods and features tailored for their toplevel roleas illustrated in example - example - pp \gui\tour\toplevel py ""... |
4,994 | there are few operational details worth noticing hereall of which are more obvious if you run this script on your machineintercepting closesprotocol because the window manager close event has been intercepted by this script using the top-level widget protocol methodpressing the in the top-right corner doesn' do anythin... |
4,995 | to kill all the windows at once and end the gui application (reallyits active mainloop call)the root window' button runs the quit method instead that ispressing the root window' button ends the program in generalthe quit method immediately ends the entire application and closes all its windows it can be called through ... |
4,996 | lower raise and lower window with respect to its siblings (lift is the tk raise commandbut avoids python reserved wordsee the alarm scripts near the end of for usage menus each top-level window can have its own window menus tooboth the tk and the toplevel widgets have menu option used to associate horizontal menu bar o... |
4,997 | nowthe next scheduled stop on this tour explores one of the more common uses of top-level windows dialogs dialogs are windows popped up by script to provide or request additional information they come in two flavorsmodal and nonmodalmodal these dialogs block the rest of the interface until the dialog window is dismisse... |
4,998 | showinfo('no''quit has been cancelled'errmsg 'sorryno spam allowed!button(text='quit'command=callbackpack(fill=xbutton(text='spam'command=(lambdashowerror('spam'errmsg))pack(fill=xmainloop( lambda anonymous function is used here to wrap the call to showerror so that it is passed two hardcoded arguments (rememberbutton-... |
4,999 | there is nothing the user can do with figure - ' dialog but press ok if no is clicked in figure - ' quit verification dialoga showinfo call creates the pop up in figure - instead finallyif the spam button is clicked in the main windowthe standard dialog captured in figure - is generated with the standard showerror call... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.