[~%@sdZddlZejdkr4ddlmZnyddlZWn;ek rZzeeedWYddZ[XnXej Z ddl Tddl Z dZ e ejZe ejZejZejZejZe jdZe jd e jZd d Zd d ZddZy ejZWnek rIYnXddZy ejZWnek rwYnXddddZGdddZda da!ddZ"ddZ#dddZ$da%GdddZ&Gdd d e&Z'Gd!d"d"e&Z(Gd#d$d$e&Z)Gd%d&d&e&Z*dd'd(Z+e,Z-e Z.d)d*Z/Gd+d,d,Z0Gd-d.d.Z1Gd/d0d0Z2Gd1d2d2Z3Gd3d4d4Z4Gd5d6d6e0e4Z5ddd6dd7d8Z6Gd9d:d:Z7Gd;d<d<Z8Gd=d>d>Z9Gd?d@d@e0Z:GdAdBdBe:e7e8e9Z;GdCdDdDe:e4Z<GdEdFdFe;Z=GdGdHdHe;e2e3Z>GdIdJdJe;Z?GdKdLdLe;e2Z@GdMdNdNe;ZAGdOdPdPe;ZBGdQdRdRe;e2e3ZCGdSdTdTe;ZDGdUdVdVe;ZEGdWdXdXe;ZFGdYdZdZe;ZGGd[d\d\e;ZHGd]d^d^e;ZIGd_d`d`e;e2e3ZJGdadbdbZKGdcddddeEZLGdedfdfZMGdgdhdheMZNGdidjdjeMZOdkdlZPdmdnZQGdodpdpe;e2ZRGdqdrdre;ZSGdsdtdte;ZTGdudvdve=ZUGdwdxdxe=ZVdydzZWeXd{kreWndS)|a8Wrapper functions for Tcl/Tk. Tkinter provides classes which allow the display, positioning and control of widgets. Toplevel widgets are Tk and Toplevel. Other widgets are Frame, Label, Entry, Text, Canvas, Button, Radiobutton, Checkbutton, Scale, Listbox, Scrollbar, OptionMenu, Spinbox LabelFrame and PanedWindow. Properties of the widgets are specified with keyword arguments. Keyword arguments have the same name as the corresponding resource under Tk. Widgets are positioned with one of the geometry managers Place, Pack or Grid. These managers can be called with methods place, pack, grid available in every Widget. Actions are bound to events by resources (e.g. keyword argument command) or with the method bind. Example (Hello, World): import tkinter from tkinter.constants import * tk = tkinter.Tk() frame = tkinter.Frame(tk, relief=RIDGE, borderwidth=2) frame.pack(fill=BOTH,expand=1) label = tkinter.Label(frame, text="Hello, World") label.pack(fill=X, expand=1) button = tkinter.Button(frame,text="Exit",command=tk.destroy) button.pack(side=BOTTOM) tk.mainloop() NZwin32)_fixz', please install the python3-tk package)*z([\\{}])z([\s])cCsdjtt|S)zInternal function. )joinmap _stringify)valuer &/usr/lib/python3.4/tkinter/__init__.py_join<sr cCst|ttfrjt|dkrWt|d}|ddkrgd|}qgqdt|}n}t|}|sd}nbtj|rtj d|}t j d|}n,|ddkst j|rd|}n|S)zInternal function.rr{z{%s}z{}z\\\1") isinstancelisttuplelenrr str _magic_researchsub _space_re)r r r r r@s   rcCs_f}xR|D]J}t|ttfr;|t|}q |dk r ||f}q q W|S)zInternal function.N)rrr_flatten)seqresitemr r r rUs  rcCst|tr|St|tdtfr2|Si}xt|D]y}y|j|WqEttfk r}z9td|x$|j D]\}}|||c Cs5yt|}Wntk r$YnXt|dS)zBInternal function. Calling it will raise the exception SystemExit.N)int ValueError SystemExit)coder r r _exits  rCc@seZdZdZdZdZdZdddddZddZdd Z d d Z e Z d d Z ddZ e ZddZddZddZdS)VariablezClass to define value holders for e.g. buttons. Subclasses StringVar, IntVar, DoubleVar, BooleanVar are specializations that constrain the type of the value returned from get().NcCs|dk r+t|t r+tdn|s:t}n|j|_|j|_|rg||_ndtt |_t d7a |dk r|j |n:|jj |jj dd|js|j |j ndS)a.Construct a variable MASTER can be given as master widget. VALUE is an optional value (defaults to "") NAME is an optional Tcl name (defaults to PY_VARnum). If NAME matches an existing variable and VALUE is omitted then the existing value is retained. Nzname must be a stringPY_VARrinfoexists)rrr r;_rootr/_tk_namerepr_varnum initialize getbooleancall_default)selfmasterr namer r r __init__s      'zVariable.__init__cCs|jdkrdS|jj|jjdd|jrP|jj|jn|jdk rx!|jD]}|jj|qiWd|_ndS)zUnset the variable in Tcl.NrGrH)rJrOrPrKZglobalunsetvar _tclCommands deletecommand)rRrTr r r __del__s'zVariable.__del__cCs|jS)z'Return the name of the variable in Tcl.)rK)rRr r r __str__szVariable.__str__cCs|jj|j|S)zSet the variable to VALUE.)rJZ globalsetvarrK)rRr r r r setsz Variable.setcCs|jj|jS)zReturn value of variable.)rJ globalgetvarrK)rRr r r get sz Variable.getcCst|d|j}tt|}y |j}Wntk rHYnXy||j}Wntk rnYnX|jj|||j dkrg|_ n|j j ||jj dd|j |||S)a Define a trace callback for the variable. MODE is one of "r", "w", "u" for read, write, undefine. CALLBACK must be a function which is called when the variable is read, written or undefined. Return the name of the callback. Ntracevariable) CallWrapper__call__rLid__func__rr6rJ createcommandrVappendrPrK)rRmodecallbackfcbnamer r r trace_variables     zVariable.trace_variablec Cs\|jjdd|j|||jj|y|jj|Wntk rWYnXdS)zDelete the trace callback for a variable. MODE is one of "r", "w", "u" for read, write, undefine. CBNAME is the name of the callback returned from trace_variable or trace. r]ZvdeleteN)rJrPrKrWrVremover@)rRrerhr r r trace_vdelete)s  zVariable.trace_vdeletecs8fddjjjjddjDS)z&Return all trace callback information.cs"g|]}jj|qSr )rJsplit).0x)rRr r 7s z(Variable.trace_vinfo..r]Zvinfo)rJr+rPrK)rRr )rRr trace_vinfo5szVariable.trace_vinfocCs(|jj|jjko'|j|jkS)zComparison for equality (==). Note: if the Variable's master matters to behavior also compare self._master == other._master ) __class__r6rK)rRotherr r r __eq__9szVariable.__eq__)r6r7r8r9rQrJrVrUrXrYrZrNr\rir]rkrprsr r r r rDs      rDc@s=eZdZdZdZdddddZddZdS) StringVarz#Value holder for strings variables.rENcCstj||||dS)a6Construct a string variable. MASTER can be given as master widget. VALUE is an optional value (defaults to "") NAME is an optional Tcl name (defaults to PY_VARnum). If NAME matches an existing variable and VALUE is omitted then the existing value is retained. N)rDrU)rRrSr rTr r r rUEs zStringVar.__init__cCs2|jj|j}t|tr(|St|S)z#Return value of variable as string.)rJr[rKrr)rRr r r r r\Qsz StringVar.get)r6r7r8r9rQrUr\r r r r rtBs  rtc@s=eZdZdZdZdddddZddZdS)IntVarz#Value holder for integer variables.rNcCstj||||dS)a7Construct an integer variable. MASTER can be given as master widget. VALUE is an optional value (defaults to 0) NAME is an optional Tcl name (defaults to PY_VARnum). If NAME matches an existing variable and VALUE is omitted then the existing value is retained. N)rDrU)rRrSr rTr r r rU[s zIntVar.__init__cCst|jj|jS)z/Return the value of the variable as an integer.)getintrJr[rK)rRr r r r\gsz IntVar.get)r6r7r8r9rQrUr\r r r r ruXs  ruc@s=eZdZdZdZdddddZddZdS) DoubleVarz!Value holder for float variables.gNcCstj||||dS)a6Construct a float variable. MASTER can be given as master widget. VALUE is an optional value (defaults to 0.0) NAME is an optional Tcl name (defaults to PY_VARnum). If NAME matches an existing variable and VALUE is omitted then the existing value is retained. N)rDrU)rRrSr rTr r r rUns zDoubleVar.__init__cCst|jj|jS)z,Return the value of the variable as a float.) getdoublerJr[rK)rRr r r r\zsz DoubleVar.get)r6r7r8r9rQrUr\r r r r rwks  rwc@s=eZdZdZdZdddddZddZdS) BooleanVarz#Value holder for boolean variables.FNcCstj||||dS)a:Construct a boolean variable. MASTER can be given as master widget. VALUE is an optional value (defaults to False) NAME is an optional Tcl name (defaults to PY_VARnum). If NAME matches an existing variable and VALUE is omitted then the existing value is retained. N)rDrU)rRrSr rTr r r rUs zBooleanVar.__init__c CsHy#|jj|jj|jSWntk rCtdYnXdS)z+Return the value of the variable as a bool.z invalid literal for getboolean()N)rJrOr[rKTclErrorr@)rRr r r r\s# zBooleanVar.get)r6r7r8r9rQrUr\r r r r ry~s  rycCstjj|dS)zRun the main loop of Tcl.N)r;r/mainloop)nr r r r{sr{c Cs9ytjj|SWntk r4tdYnXdS)z1Convert true and false to integer values 1 and 0.z invalid literal for getboolean()N)r;r/rOrzr@)sr r r rOs rOc@s eZdZdZdZddZddZdddZd d Zd d Z d dZ dddZ e Z dddZ dddZddddZdddZeZeZddZddZeZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zdd-d.Zd/d0Z d1d2Z!d3d4d5Z"d6d7Z#d8d9Z$d:d;Z%d<d=Z&d>d?Z'd@dAZ(dBdCZ)dDdEZ*ddFdGZ+dHdIZ,dJdKZ-ddLdMZ.dNdOZ/dPdQZ0dRdSZ1dTdUZ2dVdWZ3dXdYZ4ddZd[Z5dd\d]Z6e6Z7dd^d_Z8d3d`daZ9d3dbdcZ:dddeZ;dfdgZ<dhdiZ=djdkZ>d3dldmZ?dndoZ@dpdqZAdrdsZBdtduZCdvdwZDdxdyZEd3dzd{ZFd|d}ZGd~dZHddZIddZJd3ddZKddZLddZMddZNddZOddZPddZQddZRddZSddZTddZUddZVddZWddZXddZYddZZddZ[ddZ\ddZ]ddZ^ddZ_ddZ`ddZad3ddZbddZcddZdddZeddZfddZgddZhddZiddZjddZkddZlddZmdddZndddZodddddZpdddZqdddddZrddZsdddddZtddZud3ddZvddZwddZxddZyddZzddZ{e|ddZ}dddZ~ddZeZddddZeZddZd@ZdjeZddZddZd d Zd d Zd dZdddZeZddZeZddZddZddZdgZeddZeZddZeZddZdd d!ZeZddddd"d#ZeZd$d%Zd&d'Zid(d)ZeZd*d+Zed,d-Zid.d/ZeZd0d1ZeZddd2d3Zd4d5Zd6d7Zd8d9Zdd:d;Zd<d=Zd>d?ZdS(AMisczRInternal class. Base class which defines methods common for interior widgets.NcCsC|jdk r?x!|jD]}|jj|qWd|_ndS)zkInternal function. Delete all Tcl commands created for this widget in the Tcl interpreter.N)rVr/rW)rRrTr r r destroysz Misc.destroyc Cs=|jj|y|jj|Wntk r8YnXdS)zDInternal function. Delete the Tcl command provided in NAME.N)r/rWrVrjr@)rRrTr r r rWs  zMisc.deletecommandcCs"|jj|jjdd|S)zSet Tcl internal variable, whether the look and feel should adhere to Motif. A parameter of 1 means adhere to Motif (e.g. no color change if mouse passes over slider). Returns the set value.rZtk_strictMotif)r/rOrP)rRbooleanr r r rszMisc.tk_strictMotifcCs|jjddS)zDChange the color scheme to light brown as used in Tk 3.6 and before. tk_bisqueN)r/rP)rRr r r rszMisc.tk_bisquecOs4|jjdt|tt|jdS)a Set a new color scheme for all widget elements. A single color as argument will cause that all colors of Tk widget elements are derived from this. Alternatively several keyword parameters and its associated colors can be given. The following keywords are valid: activeBackground, foreground, selectColor, activeForeground, highlightBackground, selectBackground, background, highlightColor, selectForeground, disabledForeground, insertBackground, troughColor. tk_setPaletteN)z tk_setPalette)r/rPrrr")rRargskwr r r rs zMisc.tk_setPalettecGs&ddl}|jdtdddS)z)Do not use. Needed in Tk 3.6 and earlier.rNz4tk_menuBar() does nothing and will be removed in 3.6 stacklevelr))warningswarnDeprecationWarning)rRrrr r r tk_menuBars  zMisc.tk_menuBarrFcCs|jjdd|dS)zWait until the variable is modified. A parameter of type IntVar, StringVar, DoubleVar or BooleanVar must be given.tkwaitr^N)r/rP)rRrTr r r wait_variableszMisc.wait_variablecCs2|dkr|}n|jjdd|jdS)zQWait until a WIDGET is destroyed. If no parameter is given self is used.Nrwindow)r/rP_w)rRrr r r wait_windows  zMisc.wait_windowcCs2|dkr|}n|jjdd|jdS)zxWait until the visibility of a WIDGET changes (e.g. it appears). If no parameter is given self is used.NrZ visibility)r/rPr)rRrr r r wait_visibilitys  zMisc.wait_visibility1cCs|jj||dS)zSet Tcl variable NAME to VALUE.N)r/setvar)rRrTr r r r rsz Misc.setvarcCs|jj|S)z"Return value of Tcl variable NAME.)r/getvar)rRrTr r r rsz Misc.getvarc Cs9y|jj|SWntk r4tdYnXdS)zPReturn a boolean value for Tcl boolean values true and false given as parameter.z invalid literal for getboolean()N)r/rOrzr@)rRr}r r r rOs zMisc.getbooleancCs|jjd|jdS)zDirect input focus to this widget. If the application currently does not have the focus this widget will get the focus if the application gets the focus through the window manager.focusN)r/rPr)rRr r r focus_setszMisc.focus_setcCs|jjdd|jdS)ztDirect input focus to this widget even if the application does not have the focus. Use with caution!rz-forceN)r/rPr)rRr r r focus_force szMisc.focus_forcecCs6|jjd}|dks%| r)dS|j|S)zReturn the widget which has currently the focus in the application. Use focus_displayof to allow working with several displays. Return None if application does not have the focus.rnoneN)r/rP _nametowidget)rRrTr r r focus_getszMisc.focus_getcCs?|jjdd|j}|dks.| r2dS|j|S)zReturn the widget which has currently the focus on the display where this widget is located. Return None if the application does not have the focus.rz -displayofrN)r/rPrr)rRrTr r r focus_displayofszMisc.focus_displayofcCs?|jjdd|j}|dks.| r2dS|j|S)zyReturn the widget which would have the focus if top level for this widget gets the focus from the window manager.rz-lastforrN)r/rPrr)rRrTr r r focus_lastfor!szMisc.focus_lastforcCs|jjddS)zXThe widget under mouse will get automatically focus. Can not be disabled easily.tk_focusFollowsMouseN)r/rP)rRr r r r'szMisc.tk_focusFollowsMousecCs/|jjd|j}|s"dS|j|S)anReturn the next widget in the focus order which follows widget which has currently the focus. The focus order first goes to the next child, then to the children of the child recursively and then to the next sibling which is higher in the stacking order. A widget is omitted if it has the takefocus resource set to 0. tk_focusNextN)r/rPrr)rRrTr r r r+s zMisc.tk_focusNextcCs/|jjd|j}|s"dS|j|S)zHReturn previous widget in the focus order. See tk_focusNext for details. tk_focusPrevN)r/rPrr)rRrTr r r r7szMisc.tk_focusPrevcslsjjd|nLfdd}j|_j|jjd|SdS)aCall function once after given time. MS specifies the time in milliseconds. FUNC gives the function which shall be called. Additional parameters are given as parameters to the function call. Return identifier to cancel scheduling with after_cancel.aftercs<zWdyjWntk r6YnXXdS)N)rWrzr )rfuncrTrRr r callitGs  zMisc.after..callitN)r/rPr6 _register)rRZmsrrrr )rrrTrRr r<s  z Misc.aftercGs|jd||S)zCall FUNC once if the Tcl main loop has no event to process. Return an identifier to cancel the scheduling with after_cancel.Zidle)r)rRrrr r r after_idleRszMisc.after_idlec Csny?|jjdd|}|jj|d}|j|Wntk rSYnX|jjdd|dS)zCancel scheduling of function identified with ID. Identifier returned by after or after_idle must be given as first parameter.rrGrZcancelN)r/rPr+rWrz)rRradataZscriptr r r after_cancelYs zMisc.after_cancelrcCs!|jjd|j|dS)zRing a display's bell.bellN)zbell)r/rP _displayof)rR displayofr r r rgsz Misc.bellc Ksd|kre|jdkrey+d|d<|jjd|j|SWqetk ra|d=YqeXn|jjd|j|S)aRetrieve data from the clipboard on window's display. The window keyword defaults to the root window of the Tkinter application. The type keyword specifies the form in which the data is to be returned and should be an atom name such as STRING or FILE_NAME. Type defaults to STRING, except on X11, where the default is to try UTF8_STRING and fall back to STRING. This command is equivalent to: selection_get(CLIPBOARD) rx11 UTF8_STRING clipboardr\)rget)rr)_windowingsystemr/rP_optionsrz)rRrr r r clipboard_getls ! zMisc.clipboard_getcKs=d|kr|j|d.)r/rlrPrrr)rRrrr )rRr winfo_visualsavailables  zMisc.winfo_visualsavailablecCs.|ddtt|j|ddS)zInternal function.Nr)rr_Misc__winfo_getint)rRr1r r r Z__winfo_parseitemszMisc.__winfo_parseitemcCs t|dS)zInternal function.r)r?)rRrnr r r Z__winfo_getintszMisc.__winfo_getintcCst|jjdd|jS)zReturn the height of the virtual root window associated with this widget in pixels. If there is no virtual root window return the height of the screen.rZ vrootheight)rvr/rPr)rRr r r winfo_vrootheightszMisc.winfo_vrootheightcCst|jjdd|jS)zReturn the width of the virtual root window associated with this widget in pixel. If there is no virtual root window return the width of the screen.rZ vrootwidth)rvr/rPr)rRr r r winfo_vrootwidthszMisc.winfo_vrootwidthcCst|jjdd|jS)ziReturn the x offset of the virtual root relative to the root window of the screen of this widget.rZvrootx)rvr/rPr)rRr r r winfo_vrootxszMisc.winfo_vrootxcCst|jjdd|jS)ziReturn the y offset of the virtual root relative to the root window of the screen of this widget.rZvrooty)rvr/rPr)rRr r r winfo_vrootyszMisc.winfo_vrootycCst|jjdd|jS)z Return the width of this widget.rwidth)rvr/rPr)rRr r r winfo_widthszMisc.winfo_widthcCst|jjdd|jS)zVReturn the x coordinate of the upper left corner of this widget in the parent.rrn)rvr/rPr)rRr r r winfo_xsz Misc.winfo_xcCst|jjdd|jS)zVReturn the y coordinate of the upper left corner of this widget in the parent.ry)rvr/rPr)rRr r r winfo_ysz Misc.winfo_ycCs|jjddS)zEEnter event loop until all pending events have been processed by Tcl.rN)r/rP)rRr r r rsz Misc.updatecCs|jjdddS)zEnter event loop until all idle callbacks have been called. This will update the display of windows but not process events caused by the user.rZ idletasksN)r/rP)rRr r r update_idletasksszMisc.update_idletaskscCsK|dkr.|jj|jjd|jS|jjd|j|dS)a,Set or get the list of bindtags for this widget. With no argument return the list of all bindtags associated with this widget. With a list of strings as argument the bindtags are set to this list. The bindtags determine in which order events are processed (see bind).Nbindtags)r/r+rPr)rRZtagListr r r r"s  z Misc.bindtagsrcCst|tr,|jj|||fn|r|j||j|}d|rYdp\d||jf}|jj|||f|S|r|jj||fS|jj|jj|SdS)zInternal function.z"%sif {"[%s %s]" == "break"} break +rEN)rrr/rPr _substitute_subst_format_strr+)rRwhatsequencerr needcleanupfuncidrr r r _bind s z Misc._bindcCs|jd|jf|||S)aOBind to this widget at event SEQUENCE a call to function FUNC. SEQUENCE is a string of concatenated event patterns. An event pattern is of the form where MODIFIER is one of Control, Mod2, M2, Shift, Mod3, M3, Lock, Mod4, M4, Button1, B1, Mod5, M5 Button2, B2, Meta, M, Button3, B3, Alt, Button4, B4, Double, Button5, B5 Triple, Mod1, M1. TYPE is one of Activate, Enter, Map, ButtonPress, Button, Expose, Motion, ButtonRelease FocusIn, MouseWheel, Circulate, FocusOut, Property, Colormap, Gravity Reparent, Configure, KeyPress, Key, Unmap, Deactivate, KeyRelease Visibility, Destroy, Leave and DETAIL is the button number for ButtonPress, ButtonRelease and DETAIL is the Keysym for KeyPress and KeyRelease. Examples are for pressing Control and mouse button 1 or for pressing A and the Alt key (KeyPress can be omitted). An event pattern can also be a virtual event of the form <> where AString can be arbitrary. This event can be generated by event_generate. If events are concatenated they must appear shortly after each other. FUNC will be called if the event sequence occurs with an instance of Event as argument. If the return value of FUNC is "break" no further bound function is invoked. An additional boolean parameter ADD specifies whether FUNC will be called additionally to the other bound function or whether it will replace the previous function. Bind will return an identifier to allow deletion of the bound function with unbind without memory leak. If FUNC or SEQUENCE is omitted the bound function or list of bound events are returned.bind)r*r)rRr'rrr r r r+s'z Misc.bindcCs6|jjd|j|d|r2|j|ndS)zWUnbind for this widget for event SEQUENCE the function identified with FUNCID.r+rEN)r/rPrrW)rRr'r)r r r unbindDsz Misc.unbindcCs|jd|||dS)aBind to all widgets at an event SEQUENCE a call to function FUNC. An additional boolean parameter ADD specifies whether FUNC will be called additionally to the other bound function or whether it will replace the previous function. See bind for the return value.r+allr)zbindzall)r*)rRr'rrr r r bind_allJsz Misc.bind_allcCs|jjdd|ddS)z8Unbind for all widgets for event SEQUENCE all functions.r+r-rEN)r/rP)rRr'r r r unbind_allPszMisc.unbind_allcCs|jd|f|||dS)a=Bind to widgets with bindtag CLASSNAME at event SEQUENCE a call of function FUNC. An additional boolean parameter ADD specifies whether FUNC will be called additionally to the other bound function or whether it will replace the previous function. See bind for the return value.r+r)r*)rRrr'rrr r r bind_classSs zMisc.bind_classcCs|jjd||ddS)zYUnbind for a all widgets with bindtag CLASSNAME for event SEQUENCE all functions.r+rEN)r/rP)rRrr'r r r unbind_class]szMisc.unbind_classcCs|jj|dS)zCall the mainloop of Tk.N)r/r{)rRr|r r r r{asz Misc.mainloopcCs|jjdS)z8Quit the Tcl interpreter. All widgets will be destroyed.N)r/quit)rRr r r r2dsz Misc.quitcCs)|r%ttt|jj|SdS)zInternal function.N)rrrvr/r+)rRrr r r rgsz Misc._getintscCs)|r%ttt|jj|SdS)zInternal function.N)rrrxr/r+)rRrr r r _getdoubleskszMisc._getdoublescCs|r|jj|SdS)zInternal function.N)r/rO)rRrr r r _getbooleanoszMisc._getbooleancCs-|rd|fS|dkr)d|jfSfS)zInternal function.z -displayofN)r)rRrr r r rss    zMisc._displayofc CsPy|jjSWn8tk rK|jjdd}|j_|SYnXdS)zInternal function.r/ZwindowingsystemN)rIZ_windowingsystem_cachedrr/rP)rRZwsr r r rzs  "zMisc._windowingsystemcCs;|rt||f}n t|}f}x|jD]\}}|dk r:|ddkru|dd}nt|r|j|}nt|ttfrg}xk|D]Q}t|tr|jt |qt|t r|jt |qPqWdj |}n|d||f}q:q:W|S)zInternal function.Nr_rr*r6) r(r"callablerrrrr?rdrrr)rRr#rrr&r'Znvrr r r rs*    z Misc._optionscCspt|jd}|}|dsD|j}|dd}nx%|D]}|s[Pn|j|}qKW|S)zPReturn the Tkinter instance of a widget identified by its Tcl name NAME..rrN)rrlrIr)rRrTwr|r r r nametowidgets   zMisc.nametowidgetcCst|||j}tt|}y |j}Wntk rHYnXy||j}Wntk rnYnX|jj|||r|j dkrg|_ n|j j |n|S)zReturn a newly created Tcl function. If this function is called, the Python function FUNC will be executed. An optional function SUBST can be given which will be executed before FUNC.N) r_r`rLrarbrr6r/rcrVrd)rRrsubstr(rgrTr r r rs     zMisc._registercCs#|}x|jr|j}q W|S)zInternal function.)rS)rRr9r r r rIs z Misc._root%#%b%f%h%k%s%t%w%x%y%A%E%K%N%W%T%X%Y%Drc#Gst|t|jkr|S|jj}t}dd}|\}}}}} } } } } }}}}}}}}}}t}|||_|||_y|||_Wnt k rYnX|||_ || |_ || |_ || |_ || |_|| |_|||_||_y|||_Wnt k rdYnX||_|||_||_y|j||_Wntk r||_YnX|||_|||_y|||_Wntk rd|_YnX|fS)zInternal function.c Ss+yt|SWntk r&|SYnXdS)z?Tk changed behavior in 8.4.2, returning "??" rather more often.N)r?r@)r}r r r getint_events z&Misc._substitute..getint_eventr)r _subst_formatr/rOr?r5serialZnumrrzrZkeycodestateZtimerrnrcharZ send_eventZkeysymZ keysym_numrrwidgetrZx_rootZy_rootdeltar@)rRrrOrvrOZnsignbrghr&r}r1r9rnrAEKNWTXYDer r r r$sN  ?        zMisc._substitutecCs8tj\}}}|j}|j|||dS)zInternal function.N)sysexc_inforIreport_callback_exception)rRexcvaltbrootr r r _report_exceptions zMisc._report_exceptioncGs|i}xo|jj|jj|D]O}|jj|}|dddf|dd||ddd.rm)r/r+rPr)rRr r r keys2s z Misc.keyscCs|jS)z+Return the window path name of this widget.)r)rRr r r rY6sz Misc.__str___noarg_cCsQ|tjkr1|j|jjdd|jS|jjdd|j|dS)aSet or get the status for propagation of geometry information. A boolean argument specifies whether the geometry information of the slaves will determine the size of this widget. If no argument is given the current setting will be returned. pack propagateN)r~rqr4r/rPr)rRflagr r r pack_propagate;szMisc.pack_propagatecs8fddjjjjddjDS)zHReturn a list of all slaves of this widget in its packing order.csg|]}j|qSr )r)rmrn)rRr r roKs z$Misc.pack_slaves..rrslaves)r/r+rPr)rRr )rRr pack_slavesHs zMisc.pack_slavescs8fddjjjjddjDS)zHReturn a list of all slaves of this widget in its packing order.csg|]}j|qSr )r)rmrn)rRr r roSs z%Misc.place_slaves..placerv)r/r+rPr)rRr )rRr place_slavesPs  zMisc.place_slavescCs |jjdd|j|dS)zThe anchor value controls how to place the grid within the master when no row/column has any weight. The default anchor is nw.gridanchorN)r/rPr)rRr{r r r grid_anchorXszMisc.grid_anchorcCsdd|jf}|dk r=|dk r=|||f}n|dk rh|dk rh|||f}n|j|jj|pdS)aReturn a tuple of integer coordinates for the bounding box of this widget controlled by the geometry manager grid. If COLUMN, ROW is given the bounding box applies from the cell with row and column 0 to the specified cell. If COL2 and ROW2 are given the bounding box starts at that cell. The returned integers specify the offset of the upper left corner in the master widget and the width and height. rzbboxN)rrr/rP)rRcolumnrowZcol2Zrow2rr r r grid_bbox_s zMisc.grid_bboxc Csnt|ttjfrjy:t|}|s1dSd|krGt|St|SWqjtk rfYqjXn|S)Nr8)rr_tkinterZTcl_Objrxrvr@)rRr Zsvaluer r r _gridconvvaluess    zMisc._gridconvvaluecCst|trn| rn|dddkr?|dd}n|dddkrbd|}n|f}n|j||}|st|j|jjd||j|d|jS|jjd||j|f|}t|dkr|j|SdS) zInternal function.rNr5r*rzr0r6r6) rrrr4r/rPrrr)rRrindexr#roptionsrr r r _grid_configures"     zMisc._grid_configurecKs|jd|||S)zConfigure column INDEX of a grid. Valid resources are minsize (minimum size of the column), weight (how much does additional space propagate to this column) and pad (how much space to let additionally).columnconfigure)r)rRrr#rr r r grid_columnconfigureszMisc.grid_columnconfigurecCs.|j|jjdd|j||p-dS)zReturn a tuple of column and row which identify the cell at which the pixel at position X and Y inside the master widget is located.rzlocationN)rr/rPr)rRrnrr r r grid_locations zMisc.grid_locationcCsQ|tjkr1|j|jjdd|jS|jjdd|j|dS)aSet or get the status for propagation of geometry information. A boolean argument specifies whether the geometry information of the slaves will determine the size of this widget. If no argument is given, the current setting will be returned. rzrsN)r~rqr4r/rPr)rRrtr r r grid_propagateszMisc.grid_propagatecKs|jd|||S)zConfigure row INDEX of a grid. Valid resources are minsize (minimum size of the row), weight (how much does additional space propagate to this row) and pad (how much space to let additionally). rowconfigure)r)rRrr#rr r r grid_rowconfigureszMisc.grid_rowconfigurecCs(|j|jjdd|jp'dS)z.rzrv)r/r+rPr)rRrr~rr )rRr grid_slavess  zMisc.grid_slavescGs'dd|f|}|jj|dS)zBind a virtual event VIRTUAL (of the form <>) to an event SEQUENCE such that the virtual event is triggered whenever SEQUENCE occurs.eventrN)r/rP)rRvirtual sequencesrr r r event_addszMisc.event_addcGs'dd|f|}|jj|dS)z-Unbind a virtual event VIRTUAL from SEQUENCE.rdeleteN)r/rP)rRrrrr r r event_deleteszMisc.event_deletecKs`dd|j|f}x4|jD]&\}}|d|t|f}q"W|jj|dS)zGenerate an event SEQUENCE. Additional keyword arguments specify parameter of the event (e.g. x, y, rootx, rooty).rZgeneratez-%sN)rr"rr/rP)rRr'rrr&r'r r r event_generateszMisc.event_generatecCs"|jj|jjdd|S)zuReturn a list of all virtual events or the information about the SEQUENCE bound to the virtual event VIRTUAL.rrG)r/r+rP)rRrr r r event_infos zMisc.event_infocCs|jj|jjddS)z*Return a list of all existing image names.imagenames)r/r+rP)rRr r r image_namesszMisc.image_namescCs|jj|jjddS)z?Return a list of all available image types (e.g. phote bitmap).rtypes)r/r+rP)rRr r r image_typesszMisc.image_types)r<r=r>r?r@rArBrCrDrErFrGrHrIrJrKrLrMrN)r6r7r8r9rVrrWrrrrrZwaitvarrrrrr?rvfloatrxrOrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrliftrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr r r r r rrrrrrrrrrrrrr rr!r"r*r+r,r.r/r0r1r{r2rr3r4rpropertyrrr:rrregisterrIrPrr%r$rirjrkrlrmconfigrn __getitem__rorprYrqrursrwrvryr|r{rr}rrrrrrrrrrrrrrrrrr r r r r~sR                                                                          (           9                     r~c@s.eZdZdZddZddZdS)r_zwInternal class. Stores function to call when some user defined Tcl function is called e.g. after an event occurred.cCs||_||_||_dS)z(Store FUNC, SUBST and WIDGET as members.N)rr;rT)rRrr;rTr r r rUs  zCallWrapper.__init__c Gs\y,|jr|j|}n|j|SWn)tk rCYn|jjYnXdS)z3Apply first function SUBST to arguments, than FUNC.N)r;rrArTri)rRrr r r r`s  zCallWrapper.__call__N)r6r7r8r9rUr`r r r r r_s  r_c@s:eZdZdZddZddZddZdS) XViewzXMix-in class for querying and changing the horizontal position of a widget's window.cGs2|jj|jd|}|s.|j|SdS)z5Query and change the horizontal position of the view.xviewN)r/rPrr3)rRrrr r r r sz XView.xviewcCs |jj|jdd|dS)zsAdjusts the view in the window so that FRACTION of the total width of the canvas is off-screen to the left.rmovetoN)r/rPr)rRfractionr r r xview_movetoszXView.xview_movetocCs#|jj|jdd||dS)z\Shift the x-view according to NUMBER which is measured in "units" or "pages" (WHAT).rscrollN)r/rPr)rRrr&r r r xview_scrollszXView.xview_scrollN)r6r7r8r9rrrr r r r rs   rc@s:eZdZdZddZddZddZdS) YViewzVMix-in class for querying and changing the vertical position of a widget's window.cGs2|jj|jd|}|s.|j|SdS)z3Query and change the vertical position of the view.yviewN)r/rPrr3)rRrrr r r r sz YView.yviewcCs |jj|jdd|dS)zsAdjusts the view in the window so that FRACTION of the total height of the canvas is off-screen to the top.rrN)r/rPr)rRrr r r yview_moveto&szYView.yview_movetocCs#|jj|jdd||dS)z\Shift the y-view according to NUMBER which is measured in "units" or "pages" (WHAT).rrN)r/rPr)rRrr&r r r yview_scroll+szYView.yview_scrollN)r6r7r8r9rrrr r r r rs   rc@seZdZdZddddddZeZddZeZdddZeZ d d Z e Z dd d Z e Z d dZeZdddZeZddZeZddZeZdddZeZddddddZeZdddZeZddddZeZddZeZddd Z e Z!dd!d"Z"e"Z#d#d$d%Z$e$Z%ddd&d'Z&e&Z'dd(d)Z(e(Z)d*d+Z*e*Z+ddd,d-Z,e,Z-ddd.d/Z.e.Z/dd0d1Z0e0Z1dd2d3Z2e2Z3ddd4d5Z4e4Z5ddd6d7Z6e6Z7dd8d9Z8e8Z9dd:d;Z:e:Z;dd<d=Z<e<Z=dd>d?Z>e>Z?d@dAZ@e@ZAdS)BWmzAProvides functions for the communication with the window manager.Nc Cs.|j|jjdd|j||||S)zInstruct the window manager to set the aspect ratio (width/height) of this widget to be between MINNUMER/MINDENOM and MAXNUMER/MAXDENOM. Return a tuple of the actual values if no argument is given.wmaspect)rr/rPr)rRZminNumerZminDenomZmaxNumerZmaxDenomr r r wm_aspect4sz Wm.wm_aspectcGs&dd|jf|}|jj|S)aThis subcommand returns or sets platform specific attributes The first form returns a list of the platform specific flags and their values. The second form returns the value for the specific option. The third form sets one or more of the values. The values are as follows: On Windows, -disabled gets or sets whether the window is in a disabled state. -toolwindow gets or sets the style of the window to toolwindow (as defined in the MSDN). -topmost gets or sets whether this is a topmost window (displays above all other windows). On Macintosh, XXXXX On Unix, there are currently no special attribute values. r attributes)rr/rP)rRrr r r wm_attributes@szWm.wm_attributescCs|jjdd|j|S)zVStore NAME in WM_CLIENT_MACHINE property of this widget. Return current value.rclient)r/rPr)rRrTr r r wm_clientVsz Wm.wm_clientcst|dkr|f}nddjf|}|rMjj|n/fddjjjj|DSdS)zStore list of window names (WLIST) into WM_COLORMAPWINDOWS property of this widget. This list contains windows whose colormaps differ from their parents. Return current list of widgets if WLIST is empty.rrcolormapwindowscsg|]}j|qSr )r)rmrn)rRr r roes z)Wm.wm_colormapwindows..N)rrr/rPr+)rRZwlistrr )rRr wm_colormapwindows[s zWm.wm_colormapwindowscCs|jjdd|j|S)zStore VALUE in WM_COMMAND property. It is the command which shall be used to invoke the application. Return current command if VALUE is None.rr)r/rPr)rRr r r r wm_commandhsz Wm.wm_commandcCs|jjdd|jS)zDeiconify this widget. If it was never mapped it will not be mapped. On Windows it will raise this widget and give it the focus.r deiconify)r/rPr)rRr r r wm_deiconifynszWm.wm_deiconifycCs|jjdd|j|S)zSet focus model to MODEL. "active" means that this widget will claim the focus itself, "passive" means that the window manager shall give the focus. Return current focus model if MODEL is None.r focusmodel)r/rPr)rRZmodelr r r wm_focusmodelsszWm.wm_focusmodelcCs|jjdd|dS)aBThe window will be unmappend from the screen and will no longer be managed by wm. toplevel windows will be treated like frame windows once they are no longer managed by wm, however, the menu option configuration will be remembered and the menus will return once the widget is managed again.rforgetN)r/rP)rRrr r r wm_forgetysz Wm.wm_forgetcCs|jjdd|jS)zAReturn identifier for decorative frame of this widget if present.rframe)r/rPr)rRr r r wm_framesz Wm.wm_framecCs|jjdd|j|S)ziSet geometry to NEWGEOMETRY of the form =widthxheight+x+y. Return current value if None is given.rr)r/rPr)rRZ newGeometryr r r wm_geometryszWm.wm_geometryc Cs.|j|jjdd|j||||S)aInstruct the window manager that this widget shall only be resized on grid boundaries. WIDTHINC and HEIGHTINC are the width and height of a grid unit in pixels. BASEWIDTH and BASEHEIGHT are the number of grid units requested in Tk_GeometryRequest.rrz)rr/rPr)rRZ baseWidthZ baseHeightZwidthIncZ heightIncr r r wm_grids z Wm.wm_gridcCs|jjdd|j|S)z~Set the group leader widgets for related widgets to PATHNAME. Return the group leader of this widget if None is given.rgroup)r/rPr)rRpathNamer r r wm_groupsz Wm.wm_groupcCsE|r%|jjdd|jd|S|jjdd|j|SdS)aSet bitmap for the iconified widget to BITMAP. Return the bitmap if None is given. Under Windows, the DEFAULT parameter can be used to set the icon for the widget and any descendents that don't have an icon set explicitly. DEFAULT can be the relative path to a .ico file (example: root.iconbitmap(default='myicon.ico') ). See Tk documentation for more information.r iconbitmapz-defaultN)r/rPr)rRbitmapdefaultr r r wm_iconbitmaps zWm.wm_iconbitmapcCs|jjdd|jS)zDisplay widget as icon.riconify)r/rPr)rRr r r wm_iconifysz Wm.wm_iconifycCs|jjdd|j|S)zVSet mask for the icon bitmap of this widget. Return the mask if None is given.riconmask)r/rPr)rRrr r r wm_iconmaskszWm.wm_iconmaskcCs|jjdd|j|S)zSSet the name of the icon for this widget. Return the name if None is given.riconname)r/rPr)rRZnewNamer r r wm_iconnameszWm.wm_iconnameFcGsH|r(|jjdd|jd|n|jjdd|j|dS)aSets the titlebar icon for this window based on the named photo images passed through args. If default is True, this is applied to all future created toplevels as well. The data in the images is taken as a snapshot at the time of invocation. If the images are later changed, this is not reflected to the titlebar icons. Multiple images are accepted to allow different images sizes to be provided. The window manager may scale provided icons to an appropriate size. On Windows, the images are packed into a Windows icon structure. This will override an icon specified to wm_iconbitmap, and vice versa. On X, the images are arranged into the _NET_WM_ICON X property, which most modern window managers support. An icon specified by wm_iconbitmap may exist simuultaneously. On Macintosh, this currently does nothing.r iconphotoz-defaultN)r/rPr)rRrrr r r wm_iconphotos"zWm.wm_iconphotocCs(|j|jjdd|j||S)zSet the position of the icon of this widget to X and Y. Return a tuple of the current values of X and X if None is given.r iconposition)rr/rPr)rRrnrr r r wm_iconpositionszWm.wm_iconpositioncCs|jjdd|j|S)zgSet widget PATHNAME to be displayed instead of icon. Return the current value if None is given.r iconwindow)r/rPr)rRrr r r wm_iconwindowszWm.wm_iconwindowcCs|jjdd|dS)zThe widget specified will become a stand alone top-level window. The window will be decorated with the window managers title bar, etc.rmanageN)r/rP)rRrTr r r wm_managesz Wm.wm_managecCs(|j|jjdd|j||S)zSet max WIDTH and HEIGHT for this widget. If the window is gridded the values are given in grid units. Return the current values if None is given.rmaxsize)rr/rPr)rRrrr r r wm_maxsizesz Wm.wm_maxsizecCs(|j|jjdd|j||S)zSet min WIDTH and HEIGHT for this widget. If the window is gridded the values are given in grid units. Return the current values if None is given.rminsize)rr/rPr)rRrrr r r wm_minsizesz Wm.wm_minsizecCs%|j|jjdd|j|S)zInstruct the window manager to ignore this widget if BOOLEAN is given with 1. Return the current value if None is given.roverrideredirect)r4r/rPr)rRrr r r wm_overrideredirectszWm.wm_overrideredirectcCs|jjdd|j|S)zInstruct the window manager that the position of this widget shall be defined by the user if WHO is "user", and by its own policy if WHO is "program".r positionfrom)r/rPr)rRwhor r r wm_positionfromszWm.wm_positionfromcCsCt|r|j|}n|}|jjdd|j||S)zBind function FUNC to command NAME for this widget. Return the function bound to NAME if None is given. NAME could be e.g. "WM_SAVE_YOURSELF" or "WM_DELETE_WINDOW".rprotocol)r7rr/rPr)rRrTrrr r r wm_protocols   zWm.wm_protocolcCs|jjdd|j||S)zyInstruct the window manager whether this width can be resized in WIDTH or HEIGHT. Both values are boolean values.r resizable)r/rPr)rRrrr r r wm_resizableszWm.wm_resizablecCs|jjdd|j|S)zInstruct the window manager that the size of this widget shall be defined by the user if WHO is "user", and by its own policy if WHO is "program".rsizefrom)r/rPr)rRrr r r wm_sizefrom szWm.wm_sizefromcCs|jjdd|j|S)zQuery or set the state of this widget as one of normal, icon, iconic (see wm_iconwindow), withdrawn, or zoomed (Windows only).rrR)r/rPr)rRZnewstater r r wm_statesz Wm.wm_statecCs|jjdd|j|S)zSet the title of this widget.rtitle)r/rPr)rRrr r r wm_titlesz Wm.wm_titlecCs|jjdd|j|S)z_Instruct the window manager that this widget is transient with regard to widget MASTER.r transient)r/rPr)rRrSr r r wm_transientszWm.wm_transientcCs|jjdd|jS)zWithdraw this widget from the screen such that it is unmapped and forgotten by the window manager. Re-draw it with wm_deiconify.rwithdraw)r/rPr)rRr r r wm_withdrawszWm.wm_withdraw)Br6r7r8r9rrrrrrrrrrrrrrrrrrrrrrzrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrRrrrrrrr r r r r1s           rc@seZdZdZdZddddddddZdd Zd d Zd d ZddZ ddZ ddZ dS)TkzzToplevel widget of Tk which represents mostly the main window of an application. It has an associated Tcl interpreter.r8Nrrc Csd|_i|_d|_d|_|dkrddl}|jjtjd}|jj |\}}|dkr||}qnd} t j |||| t ||||_|r|j ntjjs|j||ndS)a@Return a new Toplevel widget on screen SCREENNAME. A new Tcl interpreter will be created. BASENAME will be used for the identification of the profile file (see readprofile). It is constructed from sys.argv[0] without extensions if None is given. CLASSNAME is the name of the widget class.Nr.py.pyc.pyo)rrr)rSr _tkloadedr/ospathbasenamerbargvsplitextrcreate wantobjects_loadtkflagsignore_environment readprofile) rR screenNamebaseNameruseTksyncZuserZext interactiver r r rU*s        '  z Tk.__init__cCs'|js#|jj|jndS)N)rr/loadtkr)rRr r r rDs  z Tk.loadtkcCs<d|_|jjd}|tjkrFtdtj|fnt|jjd}|tjkrtdtj|fntdkrtdttn|j dkrg|_ n|jj dt |jj d t |j j d|j j d tr%t r%|an|jd |jdS) Nr tk_versionz4tk.h version (%s) doesn't match libtk.a version (%s) tcl_versionz6tcl.h version (%s) doesn't match libtcl.a version (%s)g@z)Tk 4.0 or higher is required; found Tk %sZtkerrorexitWM_DELETE_WINDOW)rr/rr TK_VERSIONr,r TCL_VERSION TkVersionrVrcr>rCrdr:r;rr)rRrrr r r rHs*     z Tk._loadtkcCslx't|jjD]}|jqW|jjd|jtj|trht |krhda ndS)zhDestroy this and all descendants widgets. This will end the application of this Tcl interpreter.rN) rrvaluesrr/rPrr~r:r;)rRr$r r r rds  z Tk.destroyc Csbddl}d|jkr+|jd}n |j}|jj|d|}|jj|d|}|jj|d|}|jj|d|}i|d6} td| |jj|r|jjd|n|jj|rtt |j | n|jj|r0|jjd|n|jj|r^tt |j | ndS) zInternal function. It reads BASENAME.tcl and CLASSNAME.tcl into the Tcl Interpreter and calls exec on the contents of BASENAME.py and CLASSNAME.py if such a file exists in the home directory.rNHOMEz.%s.tclz.%s.pyrRzfrom tkinter import *source) renvironcurdirrrexecisfiler/rPopenread) rRrrrZhomeZ class_tclZclass_pyZbase_tclZbase_pydirr r r rms$    zTk.readprofilecCsQddl}tddtj|t_|t_|t_|j|||dS)zReport callback exception on sys.stderr. Applications may want to override this internal function, and should when sys.stderr is None.rNzException in Tkinter callbackfile) tracebackr!rbstderr last_type last_valuelast_tracebackprint_exception)rRrerfrgrr r r rds     zTk.report_callback_exceptioncCst|j|S)z3Delegate attribute access to the interpreter object)getattrr/)rRattrr r r __getattr__szTk.__getattr__) r6r7r8r9rrUrrrrrdrr r r r r&s      rcCst||||S)N)r)rrrrr r r Tclsrc@sqeZdZdZiddZeZZZddZeZ ddZ e Z e j ZZ e jZZdS) PackzQGeometry manager Pack. Base class to use the methods pack_* in every widget.cKs0|jjdd|jf|j||dS)a(Pack a widget in the parent widget. Use as options: after=widget - pack it after you have packed widget anchor=NSEW (or subset) - position widget according to given direction before=widget - pack it before you will pack widget expand=bool - expand widget if parent size grows fill=NONE or X or Y or BOTH - fill widget if widget grows in=master - use master to contain this widget in_=master - see 'in' option description ipadx=amount - add internal padding in x direction ipady=amount - add internal padding in y direction padx=amount - add padding in x direction pady=amount - add padding in y direction side=TOP or BOTTOM or LEFT or RIGHT - where to add this widget. rrrmN)r/rPrr)rRr#rr r r pack_configures zPack.pack_configurecCs|jjdd|jdS)z:Unmap this widget and do not use it for the packing order.rrrN)r/rPr)rRr r r pack_forgetszPack.pack_forgetcCsQt|j|jjdd|j}d|krM|j|d|d.) r( widgetNamer/r0rVr"r/rPrrrm) rRrSr1r#rextraZclassesr&r'r r r rU@s    !zBaseWidget.__init__cCsyx't|jjD]}|jqW|jjd|j|j|jjkrh|jj|j=nt j|dS)z)Destroy this and all descendants widgets.rN) rrr rr/rPrrKrSr~)rRr$r r r rPs zBaseWidget.destroycCs|jj|j|f|S)N)r/rPr)rRrTrr r r _doWszBaseWidget._doN)r6r7r8r9r0rUrr3r r r r r/%s   r/c@seZdZdZdS)WidgetzxInternal class. Base class for a widget which can be positioned with the geometry managers Pack, Place or Grid.N)r6r7r8r9r r r r r4[s r4c@s(eZdZdZdiddZdS)Toplevelz"Toplevel widget, e.g. for dialogs.Nc Ks|rt||f}nf}x~dddddgD]g}||kr7||}|d dkrzd|d d }n d|}|||f}||=q7q7Wtj||d |i||j}|j|j|j|j|jd |jd S)a%Construct a toplevel widget with the parent MASTER. Valid resource names: background, bd, bg, borderwidth, class, colormap, container, cursor, height, highlightbackground, highlightcolor, highlightthickness, menu, relief, screen, takefocus, use, visual, width.rclass_rrZcolormaprr5r*Nrrr6r6)r(r/rUrIrrrr) rRrSr#rr2ZwmkeyrfZoptrhr r r rUds"     zToplevel.__init__)r6r7r8r9rUr r r r r5bs r5c@s|eZdZdZdiddZddZddZd d Zd d Zd dZ ddZ ddZ dS)ButtonzButton widget.NcKstj||d||dS)aUConstruct a button widget with the parent MASTER. STANDARD OPTIONS activebackground, activeforeground, anchor, background, bitmap, borderwidth, cursor, disabledforeground, font, foreground highlightbackground, highlightcolor, highlightthickness, image, justify, padx, pady, relief, repeatdelay, repeatinterval, takefocus, text, textvariable, underline, wraplength WIDGET-SPECIFIC OPTIONS command, compound, default, height, overrelief, state, width ZbuttonN)r4rU)rRrSr#rr r r rUszButton.__init__cGs|jjd|jdS)N tkButtonEnter)r/rPr)rRdummyr r r r8szButton.tkButtonEntercGs|jjd|jdS)N tkButtonLeave)r/rPr)rRr9r r r r:szButton.tkButtonLeavecGs|jjd|jdS)N tkButtonDown)r/rPr)rRr9r r r r;szButton.tkButtonDowncGs|jjd|jdS)N tkButtonUp)r/rPr)rRr9r r r r<szButton.tkButtonUpcGs|jjd|jdS)NtkButtonInvoke)r/rPr)rRr9r r r r=szButton.tkButtonInvokecCs|jj|jddS)a_Flash the button. This is accomplished by redisplaying the button several times, alternating between active and normal colors. At the end of the flash the button is left in the same normal/active state as when the command was invoked. This command is ignored if the button's state is disabled. flashN)r/rPr)rRr r r r>s z Button.flashcCs|jj|jdS)aInvoke the command associated with the button. The return value is the return value from the command, or an empty string if there is no command associated with the button. This command is ignored if the button's state is disabled. invoke)r/rPr)rRr r r r?sz Button.invoke) r6r7r8r9rUr8r:r;r<r=r>r?r r r r r7~s       r7c@seZdZdZdiddZddZddZd d Zd d Zddd dZ ddZ ddZ ddZ ddZ dddZdddddZdddZdddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<Z d=d>Z!d?d@Z"dAdBZ#dddCdDZ$dEdFZ%dGdHZ&dIdJZ'dKdLZ(dMdNZ)dOdPZ*dQdRZ+dSdTZ,dUdVZ-ddWdXZ.e.Z/dYdZZ0e0Z1d[d\Z2id]d^Z3d_d`Z4e4Z5Z6dadbZ7dcddZ8dedfdgZ9dhdiZ:djdkZ;dldmZ<dndoZ=dpdqZ>drdsZ?dS)tCanvasz?Canvas widget to display graphical elements like lines or text.NcKstj||d||dS)aConstruct a canvas widget with the parent MASTER. Valid resource names: background, bd, bg, borderwidth, closeenough, confine, cursor, height, highlightbackground, highlightcolor, highlightthickness, insertbackground, insertborderwidth, insertofftime, insertontime, insertwidth, offset, relief, scrollregion, selectbackground, selectborderwidth, selectforeground, state, takefocus, width, xscrollcommand, xscrollincrement, yscrollcommand, yscrollincrement.ZcanvasN)r4rU)rRrSr#rr r r rUs zCanvas.__init__cGs!|jj|jdf|dS)zInternal function.addtagN)r/rPr)rRrr r r rAsz Canvas.addtagcCs|j|d|dS)z*Add tag NEWTAG to all items above TAGORID.aboveN)rA)rRnewtagtagOrIdr r r addtag_aboveszCanvas.addtag_abovecCs|j|ddS)zAdd tag NEWTAG to all items.r-N)rA)rRrCr r r addtag_allszCanvas.addtag_allcCs|j|d|dS)z*Add tag NEWTAG to all items below TAGORID.belowN)rA)rRrCrDr r r addtag_belowszCanvas.addtag_belowcCs |j|d||||dS)zAdd tag NEWTAG to item which is closest to pixel at X, Y. If several match take the top-most. All items closer than HALO are considered overlapping (all are closests). If START is specified the next below this tag is taken.closestN)rA)rRrCrnrhalostartr r r addtag_closestszCanvas.addtag_closestcCs |j|d||||dS)zLAdd tag NEWTAG to all items in the rectangle defined by X1,Y1,X2,Y2.enclosedN)rA)rRrCx1y1x2y2r r r addtag_enclosedszCanvas.addtag_enclosedcCs |j|d||||dS)zWAdd tag NEWTAG to all items which overlap the rectangle defined by X1,Y1,X2,Y2. overlappingN)rA)rRrCrNrOrPrQr r r addtag_overlappingszCanvas.addtag_overlappingcCs|j|d|dS)z)Add tag NEWTAG to all items with TAGORID.withtagN)rA)rRrCrDr r r addtag_withtagszCanvas.addtag_withtagcGs,|j|jj|jdf|p+dS)z|Return a tuple of X1,Y1,X2,Y2 coordinates for a rectangle which encloses all items with tags specified as arguments.r}N)rr/rPr)rRrr r r r}sz Canvas.bboxcCs9|jj|jd||d|r5|j|ndS)zbUnbind for all items with TAGORID for event SEQUENCE the function identified with FUNCID.r+rEN)r/rPrrW)rRrDr'r)r r r tag_unbindszCanvas.tag_unbindcCs"|j|jd|f|||S)a&Bind to all items with TAGORID at event SEQUENCE a call to function FUNC. An additional boolean parameter ADD specifies whether FUNC will be called additionally to the other bound function or whether it will replace the previous function. See bind for the return value.r+)r*r)rRrDr'rrr r r tag_bindszCanvas.tag_bindcCs"t|jj|jd||S)zrReturn the canvas x coordinate of pixel position SCREENX rounded to nearest multiple of GRIDSPACING units.canvasx)rxr/rPr)rRZscreenx gridspacingr r r rYs zCanvas.canvasxcCs"t|jj|jd||S)zrReturn the canvas y coordinate of pixel position SCREENY rounded to nearest multiple of GRIDSPACING units.canvasy)rxr/rPr)rRZscreenyrZr r r r[s zCanvas.canvasycGs6dd|jj|jj|jdf|DS)z8Return a list of coordinates for the item given in ARGS.cSsg|]}t|qSr )rx)rmrnr r r ro s z!Canvas.coords..coords)r/r+rPr)rRrr r r r\ s  z Canvas.coordsc Csvt|}|d}t|ttfr>|dd}ni}t|jj|jd|||j||S)zInternal function.rNrr6r6) rrrrrvr/rPrr)rRitemTyperrr#r r r _create s    zCanvas._createcOs|jd||S)z6Create arc shaped region with coordinates x1,y1,x2,y2.Zarc)r^)rRrrr r r create_arc szCanvas.create_arccOs|jd||S)z%Create bitmap with coordinates x1,y1.r)r^)rRrrr r r create_bitmap szCanvas.create_bitmapcOs|jd||S)z)Create image item with coordinates x1,y1.r)r^)rRrrr r r create_image szCanvas.create_imagecOs|jd||S)z-Create line with coordinates x1,y1,...,xn,yn.line)r^)rRrrr r r create_line szCanvas.create_linecOs|jd||S)z)Create oval with coordinates x1,y1,x2,y2.Zoval)r^)rRrrr r r create_oval szCanvas.create_ovalcOs|jd||S)z0Create polygon with coordinates x1,y1,...,xn,yn.Zpolygon)r^)rRrrr r r create_polygon! szCanvas.create_polygoncOs|jd||S)z.Create rectangle with coordinates x1,y1,x2,y2.Z rectangle)r^)rRrrr r r create_rectangle$ szCanvas.create_rectanglecOs|jd||S)z#Create text with coordinates x1,y1.text)r^)rRrrr r r create_text' szCanvas.create_textcOs|jd||S)z+Create window with coordinates x1,y1,x2,y2.r)r^)rRrrr r r create_window* szCanvas.create_windowcGs!|jj|jdf|dS)zDelete characters of text items identified by tag or id in ARGS (possibly several times) from FIRST to LAST character (including).dcharsN)r/rPr)rRrr r r rj- sz Canvas.dcharscGs!|jj|jdf|dS)zN)r/rPr)rRr r r r> szCheckbutton.flashcCs|jj|jdS)zr?rrr r r r r s     rc@seZdZdZdiddZdddZddZd d Zd d Zd dZ ddZ ddZ ddZ e Z ddZeZddZeZddZeZddZeZddZeZdS)Entryz1Entry widget which allows to display simple text.NcKstj||d||dS)aConstruct an entry widget with the parent MASTER. Valid resource names: background, bd, bg, borderwidth, cursor, exportselection, fg, font, foreground, highlightbackground, highlightcolor, highlightthickness, insertbackground, insertborderwidth, insertofftime, insertontime, insertwidth, invalidcommand, invcmd, justify, relief, selectbackground, selectborderwidth, selectforeground, show, state, takefocus, textvariable, validate, validatecommand, vcmd, width, xscrollcommand.entryN)r4rU)rRrSr#rr r r rU s zEntry.__init__cCs |jj|jd||dS)z.Delete text from FIRST to LAST (not included).rN)r/rPr)rRfirstlastr r r r sz Entry.deletecCs|jj|jdS)zReturn the text.r\)r/rPr)rRr r r r\ sz Entry.getcCs|jj|jd|dS)zInsert cursor at INDEX.ruN)r/rPr)rRrr r r ru sz Entry.icursorcCst|jj|jd|S)zReturn position of cursor.r)rvr/rPr)rRrr r r r s z Entry.indexcCs |jj|jd||dS)zInsert STRING at INDEX.rvN)r/rPr)rRrrr r r rv sz Entry.insertcCs |jj|jdd|dS)z&Remember the current X, Y coordinates.r~rN)r/rPr)rRrnr r r r szEntry.scan_markcCs |jj|jdd|dS)zAdjust the view of the canvas to 10 times the difference between X and Y and the coordinates given in scan_mark.r~rN)r/rPr)rRrnr r r r szEntry.scan_dragtocCs |jj|jdd|dS)z9Adjust the end of the selection near the cursor to INDEX.rrN)r/rPr)rRrr r r selection_adjust szEntry.selection_adjustcCs|jj|jdddS)z,Clear the selection if it is in this widget.rrN)r/rPr)rRr r r r szEntry.selection_clearcCs |jj|jdd|dS)z*Set the fixed end of a selection to INDEX.rrN)r/rPr)rRrr r r selection_from szEntry.selection_fromcCs%|jj|jj|jddS)zSReturn True if there are characters selected in the entry, False otherwise.rZpresent)r/rOrPr)rRr r r selection_present s zEntry.selection_presentcCs#|jj|jdd||dS)z3Set the selection from START to END (not included).rrangeN)r/rPr)rRrKendr r r selection_range szEntry.selection_rangecCs |jj|jdd|dS)z-Set the variable end of a selection to INDEX.rrN)r/rPr)rRrr r r selection_to szEntry.selection_to)r6r7r8r9rUrr\rurrvrrrrrrrrrZselect_presentrZ select_rangerrr r r r r s*              rc@s(eZdZdZdiddZdS)FramezFFrame widget which may contain other widgets and can have a 3D border.NcKst||f}f}d|kr>d|df}|d=n&d|krdd|df}|d=ntj||d|i|dS)aConstruct a frame widget with the parent MASTER. Valid resource names: background, bd, bg, borderwidth, class, colormap, container, cursor, height, highlightbackground, highlightcolor, highlightthickness, relief, takefocus, visual, width.r6z-classrrN)r(r4rU)rRrSr#rr2r r r rU s    zFrame.__init__)r6r7r8r9rUr r r r r s rc@s(eZdZdZdiddZdS)Labelz0Label widget which can display text and bitmaps.NcKstj||d||dS)aConstruct a label widget with the parent MASTER. STANDARD OPTIONS activebackground, activeforeground, anchor, background, bitmap, borderwidth, cursor, disabledforeground, font, foreground, highlightbackground, highlightcolor, highlightthickness, image, justify, padx, pady, relief, takefocus, text, textvariable, underline, wraplength WIDGET-SPECIFIC OPTIONS height, state, width labelN)r4rU)rRrSr#rr r r rU szLabel.__init__)r6r7r8r9rUr r r r r s rc@s-eZdZdZdiddZddZddZd d Zdd d Zdd dZ ddZ ddZ ddZ ddZ ddZddZddZeZdddZeZdd ZeZdd!d"ZeZd#d$Zd%d&Zdd'd(ZeZdS))Listboxz3Listbox widget which can display a list of strings.NcKstj||d||dS)aConstruct a listbox widget with the parent MASTER. Valid resource names: background, bd, bg, borderwidth, cursor, exportselection, fg, font, foreground, height, highlightbackground, highlightcolor, highlightthickness, relief, selectbackground, selectborderwidth, selectforeground, selectmode, setgrid, takefocus, width, xscrollcommand, yscrollcommand, listvariable.ZlistboxN)r4rU)rRrSr#rr r r rU3 szListbox.__init__cCs|jj|jd|dS)z"Activate item identified by INDEX.activateN)r/rPr)rRrr r r r< szListbox.activatecCs(|j|jj|jd|p'dS)zxReturn a tuple of X1,Y1,X2,Y2 coordinates for a rectangle which encloses the item identified by the given index.r}N)rr/rPr)rRrr r r r}? sz Listbox.bboxcCs%|j|jj|jdp$fS)z.Return the indices of currently selected item. curselection)rr/rPr)rRr r r rC szListbox.curselectioncCs |jj|jd||dS)z+Delete items from FIRST to LAST (included).rN)r/rPr)rRrrr r r rF szListbox.deletecCsQ|dk r4|jj|jj|jd||S|jj|jd|SdS)z0Get list of items from FIRST to LAST (included).Nr\)r/r+rPr)rRrrr r r r\I s z Listbox.getcCs5|jj|jd|}|dkr+dSt|S)z+Return index of item identified with INDEX.rrN)r/rPrrv)rRrir r r rP s z Listbox.indexcGs$|jj|jd|f|dS)zInsert ELEMENTS at INDEX.rvN)r/rPr)rRrelementsr r r rvU szListbox.insertcCst|jj|jd|S)z5Get index of item which is nearest to y coordinate Y.nearest)rvr/rPr)rRrr r r rX s zListbox.nearestcCs#|jj|jdd||dS)z&Remember the current X, Y coordinates.r~rN)r/rPr)rRrnrr r r r\ szListbox.scan_markcCs#|jj|jdd||dS)zAdjust the view of the listbox to 10 times the difference between X and Y and the coordinates given in scan_mark.r~rN)r/rPr)rRrnrr r r r_ szListbox.scan_dragtocCs|jj|jd|dS)z"Scroll such that INDEX is visible.seeN)r/rPr)rRrr r r rd sz Listbox.seecCs |jj|jdd|dS)z-Set the fixed end oft the selection to INDEX.rr{N)r/rPr)rRrr r r selection_anchorg szListbox.selection_anchorcCs#|jj|jdd||dS)z2Clear the selection from FIRST to LAST (included).rrN)r/rPr)rRrrr r r rk szListbox.selection_clearcCs(|jj|jj|jdd|S)z+Return 1 if INDEX is part of the selection.rZincludes)r/rOrPr)rRrr r r selection_includesp szListbox.selection_includescCs#|jj|jdd||dS)ziSet the selection from FIRST to LAST (included) without changing the currently selected elements.rrZN)r/rPr)rRrrr r r selection_setu szListbox.selection_setcCst|jj|jdS)z-Return the number of elements in the listbox.r)rvr/rPr)rRr r r rz sz Listbox.sizecCs'|jj|jdf|d|fS)z4Return the resource value for an ITEM and an OPTION.rwr*)r/rPr)rRrrr r r rw} s zListbox.itemcgetcKs|jd|f||S)a9Configure resources of an ITEM. The values for resources are specified as keyword arguments. To get an overview about the allowed keyword arguments call the method without arguments. Valid resource names: background, bg, foreground, fg, selectbackground, selectforeground.rx)rl)rRrr#rr r r rx szListbox.itemconfigure)r6r7r8r9rUrr}rrr\rrvrrrrrZ select_anchorrrrZselect_includesrZ select_setrrwrxrr r r r r1 s2               rc@seZdZdZdiddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZdddZddZid d!Zid"d#Zid$d%Zid&d'Zid(d)Zid*d+Zid,d-Zid.d/Zid0d1Zid2d3Zid4d5Zid6d7Zdd8d9Zd:d;Zdd<d=Z e Z!d>d?Z"d@dAZ#dBdCZ$dDdEZ%dFdGZ&dHdIZ'dJdKZ(dS)LMenuzPMenu widget which allows to display menu bars, pull-down menus and pop-up menus.NcKstj||d||dS)aAConstruct menu widget with the parent MASTER. Valid resource names: activebackground, activeborderwidth, activeforeground, background, bd, bg, borderwidth, cursor, disabledforeground, fg, font, foreground, postcommand, relief, selectcolor, takefocus, tearoff, tearoffcommand, title, type.menuN)r4rU)rRrSr#rr r r rU sz Menu.__init__cCs&ddl}|jdtdddS)Nrz=tk_bindForTraversal() does nothing and will be removed in 3.6rr))rrr)rRrr r r tk_bindForTraversal s  zMenu.tk_bindForTraversalcCs|jjd|jdS)N tk_mbPost)r/rPr)rRr r r r szMenu.tk_mbPostcCs|jjddS)N tk_mbUnpost)r/rP)rRr r r r szMenu.tk_mbUnpostcCs|jjd|j|dS)Ntk_traverseToMenu)r/rPr)rRrSr r r r szMenu.tk_traverseToMenucCs|jjd|j|dS)Ntk_traverseWithinMenu)r/rPr)rRrSr r r r szMenu.tk_traverseWithinMenucCs|jjd|jS)Ntk_getMenuButtons)r/rPr)rRr r r r szMenu.tk_getMenuButtonscCs|jjd|dS)N tk_nextMenu)r/rP)rRcountr r r r szMenu.tk_nextMenucCs|jjd|dS)Ntk_nextMenuEntry)r/rP)rRrr r r r szMenu.tk_nextMenuEntrycCs|jjd|jdS)N tk_invokeMenu)r/rPr)rRr r r r szMenu.tk_invokeMenucCs|jjd|jdS)N tk_firstMenu)r/rPr)rRr r r r szMenu.tk_firstMenucCs|jjd|jdS)Ntk_mbButtonDown)r/rPr)rRr r r r szMenu.tk_mbButtonDownrEcCs#|jjd|j|||dS)z/Post the menu at position X,Y with entry ENTRY.tk_popupN)r/rPr)rRrnrrr r r r sz Menu.tk_popupcCs|jj|jd|dS)zActivate entry at INDEX.rN)r/rPr)rRrr r r r sz Menu.activatecKs0|jj|jd|f|j||dS)zInternal function.rN)r/rPrr)rRr]r#rr r r r szMenu.addcKs|jd|p|dS)zAdd hierarchical menu item.cascadeN)r)rRr#rr r r add_cascade szMenu.add_cascadecKs|jd|p|dS)zAdd checkbutton menu item.rN)r)rRr#rr r r add_checkbutton szMenu.add_checkbuttoncKs|jd|p|dS)zAdd command menu item.rN)r)rRr#rr r r add_command szMenu.add_commandcKs|jd|p|dS)zAddd radio menu item. radiobuttonN)r)rRr#rr r r add_radiobutton szMenu.add_radiobuttoncKs|jd|p|dS)zAdd separator. separatorN)r)rRr#rr r r add_separator szMenu.add_separatorcKs3|jj|jd||f|j||dS)zInternal function.rvN)r/rPrr)rRrr]r#rr r r rv sz Menu.insertcKs|j|d|p|dS)z$Add hierarchical menu item at INDEX.rN)rv)rRrr#rr r r insert_cascade szMenu.insert_cascadecKs|j|d|p|dS)z#Add checkbutton menu item at INDEX.rN)rv)rRrr#rr r r insert_checkbutton szMenu.insert_checkbuttoncKs|j|d|p|dS)zAdd command menu item at INDEX.rN)rv)rRrr#rr r r insert_command szMenu.insert_commandcKs|j|d|p|dS)zAddd radio menu item at INDEX.rN)rv)rRrr#rr r r insert_radiobutton szMenu.insert_radiobuttoncKs|j|d|p|dS)zAdd separator at INDEX.rN)rv)rRrr#rr r r insert_separator szMenu.insert_separatorcCs|dkr|}n|j||j|}}|dksL|dkr[d\}}nxat||dD]L}d|j|krot|j|d}|r|j|qqoqoW|jj|jd||dS)z7Delete menu items between INDEX1 and INDEX2 (included).Nrrrrr6)rr6) rr entryconfigr entrycgetrWr/rPr)rRindex1index2Z num_index1Z num_index2rr$r r r r s  z Menu.deletecCs |jj|jd|d|S)z>Return the resource value of an menu item for OPTION at INDEX.rr*)r/rPr)rRrrr r r r szMenu.entrycgetcKs|jd|f||S)zConfigure a menu item at INDEX.entryconfigure)rl)rRrr#rr r r r szMenu.entryconfigurecCs5|jj|jd|}|dkr+dSt|S)z4Return the index of a menu item identified by INDEX.rrN)r/rPrrv)rRrrr r r r s z Menu.indexcCs|jj|jd|S)zRInvoke a menu item identified by INDEX and execute the associated command.r?)r/rPr)rRrr r r r? sz Menu.invokecCs |jj|jd||dS)zDisplay a menu at position X,Y.postN)r/rPr)rRrnrr r r r sz Menu.postcCs|jj|jd|S)z*Return the type of the menu item at INDEX.r)r/rPr)rRrr r r r sz Menu.typecCs|jj|jddS)z Unmap a menu.unpostN)r/rPr)rRr r r r sz Menu.unpostcCst|jj|jd|S)zNReturn the x-position of the leftmost pixel of the menu item at INDEX. xposition)rvr/rPr)rRrr r r r szMenu.xpositioncCst|jj|jd|S)zEReturn the y-position of the topmost pixel of the menu item at INDEX. yposition)rvr/rPr)rRrr r r r s zMenu.yposition))r6r7r8r9rUrrrrrrrrrrrrrrrrrrrrvrrrrrrrrrrr?rrrrrr r r r r sL                    rc@s(eZdZdZdiddZdS) Menubuttonz(Menubutton widget, obsolete since Tk8.0.NcKstj||d||dS)N menubutton)r4rU)rRrSr#rr r r rU szMenubutton.__init__)r6r7r8r9rUr r r r r s rc@s(eZdZdZdiddZdS)MessagezKMessage widget to display multiline text. Obsolete since Label does it too.NcKstj||d||dS)Nmessage)r4rU)rRrSr#rr r r rU szMessage.__init__)r6r7r8r9rUr r r r r s rc@sXeZdZdZdiddZddZddZd d Zd d ZdS) RadiobuttonzGRadiobutton widget which shows only one of several buttons in on-state.NcKstj||d||dS)aConstruct a radiobutton widget with the parent MASTER. Valid resource names: activebackground, activeforeground, anchor, background, bd, bg, bitmap, borderwidth, command, cursor, disabledforeground, fg, font, foreground, height, highlightbackground, highlightcolor, highlightthickness, image, indicatoron, justify, padx, pady, relief, selectcolor, selectimage, state, takefocus, text, textvariable, underline, value, variable, width, wraplength.rN)r4rU)rRrSr#rr r r rU s zRadiobutton.__init__cCs|jj|jddS)zPut the button in off-state.rN)r/rPr)rRr r r r$ szRadiobutton.deselectcCs|jj|jddS)zFlash the button.r>N)r/rPr)rRr r r r>( szRadiobutton.flashcCs|jj|jdS)zr?rr r r r r s    rc@s[eZdZdZdiddZddZddZdd d Zd d ZdS) Scalez1Scale widget which can display a numerical scale.NcKstj||d||dS)aConstruct a scale widget with the parent MASTER. Valid resource names: activebackground, background, bigincrement, bd, bg, borderwidth, command, cursor, digits, fg, font, foreground, from, highlightbackground, highlightcolor, highlightthickness, label, length, orient, relief, repeatdelay, repeatinterval, resolution, showvalue, sliderlength, sliderrelief, state, takefocus, tickinterval, to, troughcolor, variable, width.r}N)r4rU)rRrSr#rr r r rU4 s zScale.__init__c CsI|jj|jd}yt|SWntk rDt|SYnXdS)z*Get the current value as integer or float.r\N)r/rPrrvr@rx)rRr r r r r\> s  z Scale.getcCs|jj|jd|dS)zSet the value to VALUE.rZN)r/rPr)rRr r r r rZE sz Scale.setcCs"|j|jj|jd|S)zReturn a tuple (X,Y) of the point along the centerline of the trough that corresponds to VALUE or the current value if None is given.r\)rr/rPr)rRr r r r r\H sz Scale.coordscCs|jj|jd||S)zcReturn where the point X,Y lies. Valid return values are "slider", "though1" and "though2".identify)r/rPr)rRrnrr r r rN szScale.identify) r6r7r8r9rUr\rZr\rr r r r r2 s   rc@speZdZdZdiddZddZddZd d Zd d Zd dZ ddZ dS) Scrollbarz?Scrollbar widget which displays a slider at a certain position.NcKstj||d||dS)alConstruct a scrollbar widget with the parent MASTER. Valid resource names: activebackground, activerelief, background, bd, bg, borderwidth, command, cursor, elementborderwidth, highlightbackground, highlightcolor, highlightthickness, jump, orient, relief, repeatdelay, repeatinterval, takefocus, troughcolor, width.Z scrollbarN)r4rU)rRrSr#rr r r rUU s zScrollbar.__init__cCs|jj|jd|dS)zxDisplay the element at INDEX with activebackground and activerelief. INDEX can be "arrow1","slider" or "arrow2".rN)r/rPr)rRrr r r r_ szScrollbar.activatecCs"t|jj|jd||S)znReturn the fractional change of the scrollbar setting if it would be moved by DELTAX or DELTAY pixels.rU)rxr/rPr)rRZdeltaxZdeltayr r r rUc szScrollbar.deltacCs"t|jj|jd||S)zRReturn the fractional value which corresponds to a slider position of X,Y.r)rxr/rPr)rRrnrr r r rh szScrollbar.fractioncCs|jj|jd||S)zYReturn the element under position X,Y as one of "arrow1","slider","arrow2" or "".r)r/rPr)rRrnrr r r rl szScrollbar.identifycCs|j|jj|jdS)zZReturn the current fractional values (upper and lower end) of the slider position.r\)r3r/rPr)rRr r r r\p sz Scrollbar.getcGs!|jj|jdf|dS)ziSet the fractional values of the slider position (upper and lower ends as value between 0 and 1).rZN)r/rPr)rRrr r r rZt sz Scrollbar.set) r6r7r8r9rUrrUrrr\rZr r r r rS s      rc @seZdZdZdiddZddZddZd d Zd d Zd dZ ddZ ddZ dddZ dddZ ddZddddZddZdddZdd Zd!d"Zd#d$Zd%d&Zdd'd(Zd)d*Zdd+d,Zid-d.Zd/d0Zd1d2Zd3d4Zdd5d6Zd7d8Zd9d:Zd;d<Z d=d>Z!d?d@Z"idAdBZ#dCdDZ$dEdFZ%dGdHZ&dIdJZ'dddddddddKdLZ(dMdNZ)dOdPZ*ddQdRZ+ddSdTZ,dUdVZ-ddWdXZ.e.Z/dYdZZ0dd[d\Z1dd]d^Z2dd_d`Z3ddadbZ4ddcddZ5dedfZ6ddgdhZ7didjZ8ddkdlZ9e9Z:idmdnZ;dodpZ<dqdrZ=dS)sTextz4Text widget which can display text in various forms.NcKstj||d||dS)aConstruct a text widget with the parent MASTER. STANDARD OPTIONS background, borderwidth, cursor, exportselection, font, foreground, highlightbackground, highlightcolor, highlightthickness, insertbackground, insertborderwidth, insertofftime, insertontime, insertwidth, padx, pady, relief, selectbackground, selectborderwidth, selectforeground, setgrid, takefocus, xscrollcommand, yscrollcommand, WIDGET-SPECIFIC OPTIONS autoseparators, height, maxundo, spacing1, spacing2, spacing3, state, tabs, undo, width, wrap, rgN)r4rU)rRrSr#rr r r rU} sz Text.__init__cCs(|j|jj|jd|p'dS)zReturn a tuple of (x,y,width,height) which gives the bounding box of the visible part of the character at the given index.r}N)rr/rPr)rRrr r r r} sz Text.bboxcCs|jjd|j|dS)Ntk_textSelectTo)r/rPr)rRrr r r r szText.tk_textSelectTocCs|jjd|jdS)Ntk_textBackspace)r/rPr)rRr r r r szText.tk_textBackspacecCs#|jjd|j|||dS)Ntk_textIndexCloser)r/rPr)rRarVr$r r r r szText.tk_textIndexClosercCs|jjd|j|dS)Ntk_textResetAnchor)r/rPr)rRrr r r r szText.tk_textResetAnchorcCs+|jj|jj|jd|||S)zReturn whether between index INDEX1 and index INDEX2 the relation OP is satisfied. OP is one of <, <=, ==, >=, >, or !=.compare)r/rOrPr)rRroprr r r r sz Text.comparecGsqdd|D}|||g7}|jj|jd|pAd}|dk rit|dkri|fS|SdS)aCounts the number of relevant things between the two indices. If index1 is after index2, the result will be a negative number (and this holds for each of the possible options). The actual items which are counted depends on the options given by args. The result is a list of integers, one for the result of each counting option given. Valid counting options are "chars", "displaychars", "displayindices", "displaylines", "indices", "lines", "xpixels" and "ypixels". There is an additional possible option "update", which if given then all subsequent options ensure that any possible out of date information is recalculated.cSs)g|]}|jdsd|qS)r*z-%s) startswith)rmargr r r ro s zText.count..rN)r/rPrr)rRrrrrr r r r s !z Text.countcCsK|dkr.|jj|jj|jdS|jj|jd|dS)zjTurn on the internal consistency checks of the B-Tree inside the text widget according to BOOLEAN.Ndebug)r/rOrPr)rRrr r r r s "z Text.debugcCs |jj|jd||dS)z?Delete the characters between INDEX1 and INDEX2 (not included).rN)r/rPr)rRrrr r r r sz Text.deletecCs"|j|jj|jd|S)zReturn tuple (x,y,width,height,baseline) giving the bounding box and baseline position of the visible part of the line containing the character at INDEX. dlineinfo)rr/rPr)rRrr r r r szText.dlineinfoc Ksg}d}d}|s6g}|dd}|}nzt|ts^|j|}}n|d|g7}x,|D]$} || ru|jd| ququW|j||r|j|n|jj|jd||SWd|r|j|nXdS)aReturn the contents of the widget between index1 and index2. The type of contents returned in filtered based on the keyword parameters; if 'all', 'image', 'mark', 'tag', 'text', or 'window' are given and true, then the corresponding items are returned. The result is a list of triples of the form (key, value, index). If none of the keywords are true then 'all' is used by default. If the 'command' argument is given, it is called once for each element of the list of triples, with the values of each triple serving as the arguments to the function. In this case the list is not returned.NcSs|j|||fdS)N)rd)r3r rrr r r append_triple sz Text.dump..append_triplez-commandr*dump)rrrrdr/rPrrW) rRrrrrrZ func_namerrr3r r r r s*     z Text.dumpcGs|jj|jd|S)arInternal method This method controls the undo mechanism and the modified flag. The exact behavior of the command depends on the option argument that follows the edit argument. The following forms of the command are currently supported: edit_modified, edit_redo, edit_reset, edit_separator and edit_undo edit)r/rPr)rRrr r r r s z Text.editcCs|jd|S)a;Get or Set the modified flag If arg is not specified, returns the modified flag of the widget. The insert, delete, edit undo and edit redo commands or the user can set or clear the modified flag. If boolean is specified, sets the modified flag of the widget to arg. Zmodified)r)rRrr r r edit_modified s zText.edit_modifiedcCs |jdS)a Redo the last undone edit When the undo option is true, reapplies the last undone edits provided no other edits were done since then. Generates an error when the redo stack is empty. Does nothing when the undo option is false. Zredo)r)rRr r r edit_redo szText.edit_redocCs |jdS)z(Clears the undo and redo stacks reset)r)rRr r r edit_reset szText.edit_resetcCs |jdS)znInserts a separator (boundary) on the undo stack. Does nothing when the undo option is false r)r)rRr r r edit_separator szText.edit_separatorcCs |jdS)aDUndoes the last edit action If the undo option is true. An edit action is defined as all the insert and delete commands that are recorded on the undo stack in between two separators. Generates an error when the undo stack is empty. Does nothing when the undo option is false Zundo)r)rRr r r edit_undo s zText.edit_undocCs|jj|jd||S)z5Return the text from INDEX1 to INDEX2 (not included).r\)r/rPr)rRrrr r r r\+ szText.getcCsk|dddkr#d|}n|dddkrL|dd}n|jj|jdd||S) z9Return the value of OPTION of an embedded image at INDEX.Nrr*r5rrnr6r6)r/rPr)rRrrr r r image_cget/ s  zText.image_cgetcKs|jdd|f||S)z%Configure an embedded image at INDEX.rrm)rl)rRrr#rr r r image_configure6 szText.image_configurecKs+|jj|jdd||j||S)z"Create an embedded image at INDEX.rr)r/rPrr)rRrr#rr r r image_create9 s zText.image_createcCs|jj|jddS)z3Return all names of embedded images in this widget.rr)r/rPr)rRr r r r> szText.image_namescCst|jj|jd|S)z1Return the index in the form line.char for INDEX.r)rr/rPr)rRrr r r rA sz Text.indexcGs'|jj|jd||f|dS)zInsert CHARS before the characters at INDEX. An additional tag can be given in ARGS. Additional CHARS and tags can follow in ARGS.rvN)r/rPr)rRrcharsrr r r rvD sz Text.insertcCs"|jj|jdd||fS)zChange the gravity of a mark MARKNAME to DIRECTION (LEFT or RIGHT). Return the current value if None is given for DIRECTION.rZgravity)r/rPr)rRmarkNameZ directionr r r mark_gravityH s zText.mark_gravitycCs%|jj|jj|jddS)zReturn all mark names.rr)r/r+rPr)rRr r r mark_namesM szText.mark_namescCs#|jj|jdd||dS)z0Set mark MARKNAME before the character at INDEX.rrZN)r/rPr)rRrrr r r mark_setQ sz Text.mark_setcGs$|jj|jddf|dS)zDelete all marks in MARKNAMES.rZunsetN)r/rPr)rRZ markNamesr r r mark_unsetT szText.mark_unsetcCs"|jj|jdd|p!dS)z-Return the name of the next mark after INDEX.rnextN)r/rPr)rRrr r r mark_nextW szText.mark_nextcCs"|jj|jdd|p!dS)z2Return the name of the previous mark before INDEX.rZpreviousN)r/rPr)rRrr r r mark_previousZ szText.mark_previouscKs/|jj|jdd||j||dS)aCreates a peer text widget with the given newPathName, and any optional standard configuration options. By default the peer will have the same start and end line as the parent widget, but these can be overriden with the standard configuration options.peerrN)r/rPrr)rRZ newPathNamer#rr r r peer_create] szText.peer_createcCs%|jj|jj|jddS)zYReturns a list of peers of this widget (this does not include the widget itself).rr)r/r+rPr)rRr r r peer_namesd szText.peer_namescGs&|jj|jd||||dS)zReplaces the range of characters between index1 and index2 with the given characters and tags specified by args. See the method insert for some more information about args, and the method delete for information about the indices.replaceN)r/rPr)rRrrrrr r r rh sz Text.replacecCs#|jj|jdd||dS)z&Remember the current X, Y coordinates.r~rN)r/rPr)rRrnrr r r ro szText.scan_markcCs#|jj|jdd||dS)z~Adjust the view of the text to 10 times the difference between X and Y and the coordinates given in scan_mark.r~rN)r/rPr)rRrnrr r r rr szText.scan_dragtoc Cs(|jdg} |r%| jdn|r;| jdn|rQ| jdn|rg| jdn|r}| jdn| r| jdn| r| jd| j| n|r|d d kr| jd n| j|| j||r | j|nt|jjt| S) zSearch PATTERN beginning from INDEX until STOPINDEX. Return the index of the first character of a match or an empty string.rz -forwardsz -backwardsz-exactz-regexpz-nocasez-elidez-countrr*z--)rrdrr/rPr) rRrrZ stopindexZforwardsZ backwardsexactZregexpZnocaserZeliderr r r rw s.   z Text.searchcCs|jj|jd|dS)z3Scroll such that the character at INDEX is visible.rN)r/rPr)rRrr r r r szText.seecGs*|jj|jdd||f|dS)z|Add tag TAGNAME to all characters between INDEX1 and index2 in ARGS. Additional pairs of indices may follow in ARGS.tagrN)r/rPr)rRtagNamerrr r r tag_add s z Text.tag_addcCs<|jj|jdd||d|r8|j|ndS)zgUnbind for all characters with TAGNAME for event SEQUENCE the function identified with FUNCID.rr+rEN)r/rPrrW)rRrr'r)r r r rW s"zText.tag_unbindcCs%|j|jdd|f|||S)a+Bind to all characters with TAGNAME at event SEQUENCE a call to function FUNC. An additional boolean parameter ADD specifies whether FUNC will be called additionally to the other bound function or whether it will replace the previous function. See bind for the return value.rr+)r*r)rRrr'rrr r r rX sz Text.tag_bindcCsk|dddkr#d|}n|dddkrL|dd}n|jj|jdd||S) z+Return the value of OPTION for tag TAGNAME.Nrr*r5rrnr6r6)r/rPr)rRrrr r r tag_cget s  z Text.tag_cgetcKs|jdd|f||S)zConfigure a tag TAGNAME.rrm)rl)rRrr#rr r r tag_configure szText.tag_configurecGs$|jj|jddf|dS)zDelete all tags in TAGNAMES.rrN)r/rPr)rRZtagNamesr r r tag_delete szText.tag_deletecCs#|jj|jdd||dS)z`Change the priority of tag TAGNAME such that it is lower than the priority of BELOWTHIS.rrN)r/rPr)rRrrr r r ry szText.tag_lowercCs(|jj|jj|jdd|S)zReturn a list of all tag names.rr)r/r+rPr)rRrr r r tag_names s zText.tag_namescCs.|jj|jj|jdd|||S)zReturn a list of start and end index for the first sequence of characters between INDEX1 and INDEX2 which all have tag TAGNAME. The text is searched forward from INDEX1.rZ nextrange)r/r+rPr)rRrrrr r r tag_nextrange szText.tag_nextrangecCs.|jj|jj|jdd|||S)zReturn a list of start and end index for the first sequence of characters between INDEX1 and INDEX2 which all have tag TAGNAME. The text is searched backwards from INDEX1.rZ prevrange)r/r+rPr)rRrrrr r r tag_prevrange szText.tag_prevrangecCs#|jj|jdd||dS)zaChange the priority of tag TAGNAME such that it is higher than the priority of ABOVETHIS.rrN)r/rPr)rRrrr r r r| s zText.tag_raisecCs(|jj|jj|jdd|S)z7Return a list of ranges of text which have tag TAGNAME.rranges)r/r+rPr)rRrr r r tag_ranges szText.tag_rangescCs&|jj|jdd|||dS)zARemove tag TAGNAME from all characters between INDEX1 and INDEX2.rrjN)r/rPr)rRrrrr r r tag_remove s zText.tag_removecCsk|dddkr#d|}n|dddkrL|dd}n|jj|jdd||S) z:Return the value of OPTION of an embedded window at INDEX.Nrr*r5rrnr6r6)r/rPr)rRrrr r r window_cget s  zText.window_cgetcKs|jdd|f||S)z&Configure an embedded window at INDEX.rrm)rl)rRrr#rr r r window_configure szText.window_configurecKs3|jj|jdd|f|j||dS)zCreate a window at INDEX.rrN)r/rPrr)rRrr#rr r r window_create s zText.window_createcCs%|jj|jj|jddS)z4Return all names of embedded windows in this widget.rr)r/r+rPr)rRr r r window_names s zText.window_namescGs$|jj|jddf|dS)zObsolete function, use see.rz -pickplaceN)r/rPr)rRr&r r r yview_pickplace szText.yview_pickplace)>r6r7r8r9rUr}rrrrrrrrrrrrrrrrr\rrrrrrvrrrrrrrrrrrrrrrWrXrrZ tag_configrryrrrr|rr r r Z window_configr r rr r r r r{ sz         (                         rc@s1eZdZdZdddZddZdS)_setitz>Internal class. It wraps the command in the widget OptionMenu.NcCs||_||_||_dS)N) _setit__value _setit__var_setit__callback)rRZvarr rfr r r rU s  z_setit.__init__cGs6|jj|j|jr2|j|j|ndS)N)rrZrr)rRrr r r r` s z_setit.__call__)r6r7r8r9rUr`r r r r r s rc@s:eZdZdZddZddZddZdS) OptionMenuz?OptionMenu which allows the user to select a value from a menu.c Os%idd6|d6dd6td6dd6dd 6}tj||d |d |_t|d d dd}|_|j|_|jd}d|kr|d=n|rt d|j dn|j d|dt |||x0|D](} |j d| dt || |qW||d \}}t |r|j |}n|d||f}qW|jj dd ||f|||_dS) NzToo early to create imager/rz pyimage%rrr*r5rr) rTr;r,rr/r_last_idr(r"r7rrP) rRZimgtyperTr#rSrrr&r'r r r rU s,     zImage.__init__cCs|jS)N)rT)rRr r r rY1 sz Image.__str__c CsB|jr>y|jjdd|jWq>tk r:Yq>XndS)Nrr)rTr/rPrz)rRr r r rX2 s   z Image.__del__cCs$|jj|jdd||dS)Nrmr*)r/rPrT)rRr3r r r r ro9 szImage.__setitem__cCs|jj|jdd|S)Nrmr*)r/rPrT)rRr3r r r r; szImage.__getitem__cKsf}xt|jD]p\}}|dk r|ddkrT|dd}nt|rr|j|}n|d||f}qqW|jj|jdf|dS)zConfigure the image.Nrr5r*rr6r6)r(r"r7rr/rPrT)rRrrr&r'r r r rm= s  zImage.configurecCst|jjdd|jS)zReturn the height of the image.rr)rvr/rPrT)rRr r r rH sz Image.heightcCs|jjdd|jS)z8Return the type of the imgage, e.g. "photo" or "bitmap".rr)r/rPrT)rRr r r rL sz Image.typecCst|jjdd|jS)zReturn the width of the image.rr)rvr/rPrT)rRr r r rO sz Image.width)r6r7r8r9rrUrYrXrorrmrrrrr r r r r s        rc@seZdZdZdidddZddZddZd d Zd d Zd ddZ d ddZ ddZ dddZ ddddZ dS) PhotoImagez?Widget which can display colored images in GIF, PPM/PGM format.NcKs tj|d||||dS)ztCreate an image with NAME. Valid resource names: data, format, file, gamma, height, palette, width.ZphotoN)rrU)rRrTr#rSrr r r rUV szPhotoImage.__init__cCs|jj|jddS)zDisplay a transparent image.blankN)r/rPrT)rRr r r r\ szPhotoImage.blankcCs|jj|jdd|S)zReturn the value of OPTION.rnr*)r/rPrT)rRrr r r rn_ szPhotoImage.cgetcCs|jj|jdd|S)Nrnr*)r/rPrT)rRr3r r r rc szPhotoImage.__getitem__cCs/td|j}|jj|d|j|S)z;Return a new PhotoImage with the same image as this widget.rScopy)rr/rPrT)rR destImager r r rf szPhotoImage.copyrEcCsMtd|j}|dkr'|}n|jj|d|jd|||S)z\Return a new PhotoImage with the same image as this widget but zoom it with X and Y.rSrErz-zoom)rr/rPrT)rRrnrrr r r zoomk s  "zPhotoImage.zoomcCsMtd|j}|dkr'|}n|jj|d|jd|||S)zkReturn a new PhotoImage based on the same image as this widget but use only every Xth or Yth pixel.rSrErz -subsample)rr/rPrT)rRrnrrr r r subsampler s  "zPhotoImage.subsamplecCs|jj|jd||S)z8Return the color (red, green, blue) of the pixel at X,Y.r\)r/rPrT)rRrnrr r r r\y szPhotoImage.getcCsf|jd|f}|rR|ddkr;|dd}n|dt|}n|jj|dS)zzPut row formatted colors to image starting from position TO, e.g. image.put("{red green} {blue yellow}", to=(4,6))putr-torN)r)rTrr/rP)rRrrrr r r r| s zPhotoImage.putcCs\|jd|f}|r+|d|f}n|rH|dt|}n|jj|dS)zRWrite image to file FILENAME in FORMAT starting from position FROM_COORDS.writez-format-fromN)r!)rTrr/rP)rRfilenameformatZ from_coordsrr r r r  s zPhotoImage.write)r6r7r8r9rUrrnrrrrr\rr r r r r rT s       rc@s+eZdZdZdidddZdS) BitmapImagez"Widget which can display a bitmap.NcKs tj|d||||dS)zqCreate a bitmap with NAME. Valid resource names: background, data, file, foreground, maskdata, maskfile.rN)rrU)rRrTr#rSrr r r rU szBitmapImage.__init__)r6r7r8r9rUr r r r r$ s r$cCstjjtjjddS)Nrr)r;r/r+rPr r r r r srcCstjjtjjddS)Nrr)r;r/r+rPr r r r r src@seZdZdZdiddZddZdddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zdd!d"ZdS)#Spinboxzspinbox widget.NcKstj||d||dS)aConstruct a spinbox widget with the parent MASTER. STANDARD OPTIONS activebackground, background, borderwidth, cursor, exportselection, font, foreground, highlightbackground, highlightcolor, highlightthickness, insertbackground, insertborderwidth, insertofftime, insertontime, insertwidth, justify, relief, repeatdelay, repeatinterval, selectbackground, selectborderwidth selectforeground, takefocus, textvariable xscrollcommand. WIDGET-SPECIFIC OPTIONS buttonbackground, buttoncursor, buttondownrelief, buttonuprelief, command, disabledbackground, disabledforeground, format, from, invalidcommand, increment, readonlybackground, state, to, validate, validatecommand values, width, wrap, ZspinboxN)r4rU)rRrSr#rr r r rU szSpinbox.__init__cCs(|j|jj|jd|p'dS)aReturn a tuple of X1,Y1,X2,Y2 coordinates for a rectangle which encloses the character given by index. The first two elements of the list give the x and y coordinates of the upper-left corner of the screen area covered by the character (in pixels relative to the widget) and the last two elements give the width and height of the character, in pixels. The bounding box may refer to a region outside the visible area of the window. r}N)rr/rPr)rRrr r r r} s z Spinbox.bboxcCs|jj|jd||S)aWDelete one or more elements of the spinbox. First is the index of the first character to delete, and last is the index of the character just after the last one to delete. If last isn't specified it defaults to first+1, i.e. a single character is deleted. This command returns an empty string. r)r/rPr)rRrrr r r r s zSpinbox.deletecCs|jj|jdS)zReturns the spinbox's stringr\)r/rPr)rRr r r r\ sz Spinbox.getcCs|jj|jd|S)zAlter the position of the insertion cursor. The insertion cursor will be displayed just before the character given by index. Returns an empty string ru)r/rPr)rRrr r r ru szSpinbox.icursorcCs|jj|jd||S)z{Returns the name of the widget at position x, y Return value is one of: none, buttondown, buttonup, entry r)r/rPr)rRrnrr r r r szSpinbox.identifycCs|jj|jd|S)z;Returns the numerical index corresponding to index r)r/rPr)rRrr r r r sz Spinbox.indexcCs|jj|jd||S)zDInsert string s at index Returns an empty string. rv)r/rPr)rRrr}r r r rv szSpinbox.insertcCs|jj|jd|S)zCauses the specified element to be invoked The element could be buttondown or buttonup triggering the action associated with it. r?)r/rPr)rRelementr r r r? szSpinbox.invokecGs,|j|jj|jdf|p+fS)zInternal function.r~)rr/rPr)rRrr r r r~ sz Spinbox.scancCs|jd|S)zRecords x and the current view in the spinbox window; used in conjunction with later scan dragto commands. Typically this command is associated with a mouse button press in the widget. It returns an empty string. r)r~)rRrnr r r rszSpinbox.scan_markcCs|jd|S)aCompute the difference between the given x argument and the x argument to the last scan mark command It then adjusts the view left or right by 10 times the difference in x-coordinates. This command is typically associated with mouse motion events in the widget, to produce the effect of dragging the spinbox at high speed through the window. The return value is an empty string. r)r~)rRrnr r r r s zSpinbox.scan_dragtocGs,|j|jj|jdf|p+fS)zInternal function.r)rr/rPr)rRrr r r rszSpinbox.selectioncCs|jd|S)aLocate the end of the selection nearest to the character given by index, Then adjust that end of the selection to be at index (i.e including but not going beyond index). The other end of the selection is made the anchor point for future select to commands. If the selection isn't currently in the spinbox, then a new selection is created to include the characters between index and the most recent selection anchor point, inclusive. Returns an empty string. r)r)rRrr r r rs zSpinbox.selection_adjustcCs |jdS)zClear the selection If the selection isn't in this widget then the command has no effect. Returns an empty string. r)r)rRr r r r+szSpinbox.selection_clearcCs|jd|S)zSets or gets the currently selected element. If a spinbutton element is specified, it will be displayed depressed r&)r)rRr&r r r selection_element3szSpinbox.selection_element)r6r7r8r9rUr}rr\rurrrvr?r~rrrrrr'r r r r r% s"            r%c@s(eZdZdZdiddZdS) LabelFramezlabelframe widget.NcKstj||d||dS)aConstruct a labelframe widget with the parent MASTER. STANDARD OPTIONS borderwidth, cursor, font, foreground, highlightbackground, highlightcolor, highlightthickness, padx, pady, relief, takefocus, text WIDGET-SPECIFIC OPTIONS background, class, colormap, container, height, labelanchor, labelwidget, visual, width Z labelframeN)r4rU)rRrSr#rr r r rU?szLabelFrame.__init__)r6r7r8r9rUr r r r r(=s r(c@seZdZdZdiddZddZddZeZd d Zd d Z d dZ ddZ ddZ ddZ ddZddZddZddZdddZeZdd ZdS)! PanedWindowzpanedwindow widget.NcKstj||d||dS)aTConstruct a panedwindow widget with the parent MASTER. STANDARD OPTIONS background, borderwidth, cursor, height, orient, relief, width WIDGET-SPECIFIC OPTIONS handlepad, handlesize, opaqueresize, sashcursor, sashpad, sashrelief, sashwidth, showhandle, Z panedwindowN)r4rU)rRrSr#rr r r rUUszPanedWindow.__init__cKs-|jj|jd|f|j|dS)a+Add a child widget to the panedwindow in a new pane. The child argument is the name of the child widget followed by pairs of arguments that specify how to manage the windows. The possible options and values are the ones accepted by the paneconfigure method. rN)r/rPrr)rRrrr r r reszPanedWindow.addcCs|jj|jd|dS)zRemove the pane containing child from the panedwindow All geometry management options for child will be forgotten. rN)r/rPr)rRrr r r rjoszPanedWindow.removecCs|jj|jd||S)aIdentify the panedwindow component at point x, y If the point is over a sash or a sash handle, the result is a two element list containing the index of the sash or handle, and a word indicating whether it is over a sash or a handle, such as {0 sash} or {2 handle}. If the point is over any other part of the panedwindow, the result is an empty list. r)r/rPr)rRrnrr r r rws zPanedWindow.identifycGs,|j|jj|jdf|p+fS)zInternal function.proxy)rr/rPr)rRrr r r r*szPanedWindow.proxycCs |jdS)zBReturn the x and y pair of the most recent proxy location coord)r*)rRr r r proxy_coordszPanedWindow.proxy_coordcCs |jdS)z+Remove the proxy from the display. r)r*)rRr r r proxy_forgetszPanedWindow.proxy_forgetcCs|jd||S)z:Place the proxy at the given x and y coordinates. rx)r*)rRrnrr r r proxy_placeszPanedWindow.proxy_placecGs,|j|jj|jdf|p+fS)zInternal function.sash)rr/rPr)rRrr r r r/szPanedWindow.sashcCs|jd|S)aAReturn the current x and y pair for the sash given by index. Index must be an integer between 0 and 1 less than the number of panes in the panedwindow. The coordinates given are those of the top left corner of the region containing the sash. pathName sash dragto index x y This command computes the difference between the given coordinates and the coordinates given to the last sash coord command for the given sash. It then moves that sash the computed difference. The return value is the empty string. r+)r/)rRrr r r sash_coords zPanedWindow.sash_coordcCs|jd|S)zRecords x and y for the sash given by index; Used in conjunction with later dragto commands to move the sash. r)r/)rRrr r r sash_markszPanedWindow.sash_markcCs|jd|||S)z?Place the sash given by index at the given coordinates rx)r/)rRrrnrr r r sash_placeszPanedWindow.sash_placecCs'|jj|jdf|d|fS)zwQuery a management option for window. Option may be any value allowed by the paneconfigure subcommand panecgetr*)r/rPr)rRrrr r r r3s zPanedWindow.panecgetcKs|dkr)| r)|j|jd|St|tr\| r\|j|jd|d|S|jj|jd|f|j||dS)a Query or modify the management options for window. If no option is specified, returns a list describing all of the available options for pathName. If option is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified). If one or more option-value pairs are specified, then the command modifies the given widget option(s) to have the given value(s); in this case the command returns an empty string. The following options are supported: after window Insert the window after the window specified. window should be the name of a window already managed by pathName. before window Insert the window before the window specified. window should be the name of a window already managed by pathName. height size Specify a height for the window. The height will be the outer dimension of the window including its border, if any. If size is an empty string, or if -height is not specified, then the height requested internally by the window will be used initially; the height may later be adjusted by the movement of sashes in the panedwindow. Size may be any value accepted by Tk_GetPixels. minsize n Specifies that the size of the window cannot be made less than n. This constraint only affects the size of the widget in the paned dimension -- the x dimension for horizontal panedwindows, the y dimension for vertical panedwindows. May be any value accepted by Tk_GetPixels. padx n Specifies a non-negative value indicating how much extra space to leave on each side of the window in the X-direction. The value may have any of the forms accepted by Tk_GetPixels. pady n Specifies a non-negative value indicating how much extra space to leave on each side of the window in the Y-direction. The value may have any of the forms accepted by Tk_GetPixels. sticky style If a window's pane is larger than the requested dimensions of the window, this option may be used to position (or stretch) the window within its pane. Style is a string that contains zero or more of the characters n, s, e or w. The string can optionally contains spaces or commas, but they are ignored. Each letter refers to a side (north, south, east, or west) that the window will "stick" to. If both n and s (or e and w) are specified, the window will be stretched to fill the entire height (or width) of its cavity. width size Specify a width for the window. The width will be the outer dimension of the window including its border, if any. If size is an empty string, or if -width is not specified, then the width requested internally by the window will be used initially; the width may later be adjusted by the movement of sashes in the panedwindow. Size may be any value accepted by Tk_GetPixels. N paneconfigurer*)rjrrrrkr/rPr)rRrDr#rr r r r4sDzPanedWindow.paneconfigurecCs"|jj|jj|jdS)z+Returns an ordered list of the child panes.panes)r/r+rPr)rRr r r r5 szPanedWindow.panes)r6r7r8r9rUrrjrrr*r,r-r.r/r0r1r2r3r4Z paneconfigr5r r r r r)Ss$           Kr)c@s"eZdZdiddZdS) StudbuttonNcKsitj||d|||jd|j|jd|j|jd|j|jd|jdS)NZ studbuttonz z z<1>z)r4rUr+r8r:r;r<)rRrSr#rr r r rUs zStudbutton.__init__)r6r7r8rUr r r r r6s r6c@s"eZdZdiddZdS) TributtonNcKstj||d|||jd|j|jd|j|jd|j|jd|j|d|d<|d|dz z<1>zZbgZfgZactivebackground)r4rUr+r8r:r;r<)rRrSr#rr r r rUszTributton.__init__)r6r7r8rUr r r r r7s r7cCst}dt}tdkr,|d7}nt|d|}|jt|ddd|dd}|j||_t|dd d|j}|j|j|j|j |j dS) NzThis is Tcl/Tk version %sg333333 @u This should be a cedilla: çrgz Click me!rcSs|jjdd|jdS)Nrgz[%s])testrm)rhr r r /s z_test..ZQUIT) r TclVersionrrrr7r8rrrrr{)rhrgrr8r2r r r _test's            r;__main__)Yr9rbplatformZtkinterrr ImportErrorr%rrzZtkinter.constantsrerrrr r r:ZREADABLEZWRITABLEZ EXCEPTIONcompilerASCIIrr rrrr(r4r5r:r;r<r>rCrMrDrtrurwryr{r?rvrxrOr~r_rrrrrr r&r*r/r4r5r7r@rrrrrrrrrrrrrrrrr$rrr%r(r)r6r7r;r6r r r r s )              , m Sz',/6<A[!(n %<<