tkinter guide pdf

Page 1

CLICKHERETO DOWNLOAD

TkisagraphicslibrarywidelyusedandavailableeverywhereThelabelisusedtoadditemstotheendofthelistbox#buildastringvariabletellingtkinterhowto createandpositionourToplevelwindowworkwindow=str()+"x"+str()+"+"+str(int((scrW)/2))+"+"+str(int((scrH)/2))createtheToplevelundertheroot parent,setitsgeometryandtitletop1=Toplevel(root,bg="lightblue")ry(workwindow)tkinter-docsmainloop(n=0)nametowidget(name) optionadd(pattern,value,priority=None)optionclear()optionget(name,className)optionreadfile(fileName,priority=None)pack(cnf={},**kw) configure ThisframeworkisveryTkinterisaGUIwidgetsetforPythonThelistboxmethodsinsertImport:fromtkinterimport*orimporttkinterastk-requiresusing"tk" prefixtocommands)DefineanyvariablesneededtoestablishrootEstablishroot:root=Tk()orroot=()aWhatisit?Thisbookisnothingmorethanalistofallthe TkinterWidgets(andtheadd-onTTKWidgetsaswell)withalloftheirconfigurableattributeslistedandexplainedTkinterisaGUIwidgetsetforPythonFor completedocumentation,see:orthebookPythonandTkinterProgrammingbyJohnGrayson(Manning,,ISBN).Touseit:import*fromTkinter.fromTkinter import*Whatcanitdo?packconfigure(cnf={},**kw)packforget()packinfo()packpropagate(flag=[’noarg’])packslaves()place(cnf={},**kw) SeeWidgettkinterTheoldwayofcreatingalistbox,wastocreateanemptylistboxwidgetandthentoinsertitembyitemintothelistboxTheoldwayofcreating alistbox,wastocreateanemptylistboxwidgetandthentoinsertitembyitemintothelistboxIWelcometoTkinterGUIProgrammingbyExampleThisisnota bookonprogramminginTkinterItisverylikelythatyourversionofPythoncamewithtkinteralreadyinstalledThisdocumentcontainsonlythecommoner featuresTothereisn'treallyaverygoodreferenceguidetoTkinter'swidgetsthatshowsalloftheirattributesinoneeasytolook-upplaceWewillbeexploring howtousetheTkinterlibrary,whichisincludedalongsidemostPythoninstallsThat'swhatthisbookisTkinterisincludedwithPythonasalibraryForcomplete documentation,see:ortkinter.ItisverylikelythatyourversionofPythoncamewithtkinteralreadyinstalled.That'sit!Youcancheckifyourlocalmachinehasa workingversionoftkinterbywritingandexecutingasimplePythonprogramconsistingofthetwolinesofcodeshownbelow:importtkintertkinter test() InstallationonYourLocalMachineReferenceGuideThelistboxmethodsinsertanddeleteallowtoaddorremoveitemsaspecificpositionIt'saquickreference guidetoalloftheattributesofeverysingleTkinterwidgetlistedalphabetically,allinoneplaceReferenceGuideTkintergivesyoutheabilitytocreateWindows withwidgetsinthemCreatealistboxtheoldwayTkinterisaPythoninterfacetotheTkgraphicslibraryorThisdocumentcontainsonlythecommonerfeatures TkinterisaPythoninterfacetotheTkgraphicslibraryTkisagraphicslibrarywidelyusedandavailableeverywhereThisdocumentappliestoPythonandTkinter runningintheXWindowsystemWhatisit?Youcancheckifyourlocaltkinter-docsmainloop(n=0)nametowidget(name) optionadd(pattern,value,priority=None)optionclear()optionget(name,className)optionreadfile(fileName,priority=None)Createalistboxtheoldway. TkinterisincludedwithPythonasalibraryInstallationonYourLocalMachine

Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.