U e5d͕@sdZddlZddlZddlZejZddlTddlZdZeej Z eej Z ej Z ejZejZedZedejZddZd d Zd d Zz ejZWnek rYnXd dZz ejZWnek rYnXdyddZGdddeejZGdddZdadaddZ dzddZ!ddZ"d{ddZ#da$GdddZ%Gd d!d!e%Z&Gd"d#d#e%Z'Gd$d%d%e%Z(Gd&d'd'e%Z)d|d(d)Z*e+Z,eZ-d*d+Z.Gd,d-d-Z/Gd.d/d/Z0Gd0d1d1Z1Gd2d3d3Z2Gd4d5d5Z3Gd6d7d7e/e3Z4d}d8d9Z5Gd:d;d;Z6Gdd?d?Z8Gd@dAdAe/Z9GdBdCdCe9e6e7e8Z:GdDdEdEe9e3Z;GdFdGdGe:ZGdLdMdMe:e1Z?GdNdOdOe:Z@GdPdQdQe:ZAGdRdSdSe:e1e2ZBGdTdUdUe:ZCGdVdWdWe:ZDGdXdYdYe:ZEGdZd[d[e:ZFGd\d]d]e:ZGGd^d_d_e:ZHGd`dadae:e1e2ZIGdbdcdcZJGdddedeeDZKGdfdgdgZLGdhdidieLZMGdjdkdkeLZNdldmZOdndoZPGdpdqdqe:e1ZQGdrdsdse:ZRGdtdudue:ZSdvdwZTeUdxkreTdS)~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() N)*z([\\{}])z([\s])cCsdtt|S)Internal function. )joinmap _stringifyvaluer (/usr/lib64/python3.8/tkinter/__init__.py_join8sr cCst|ttfrHt|dkr:t|d}t|rFd|}qdt|}ntt|}|sZd}nbt|rt d|}| dd}t d|}|ddkrd |}n|ddkst |rd|}|S) rrrz{%s}z{}z\\\1 z\n"\) isinstancelisttuplelenr _magic_researchr strsubreplace _space_rer r r r r=s$          rcCs@d}|D]2}t|ttfr(|t|}q|dk r||f}q|S)rr N)rrr_flatten)seqresitemr r r rVs rc Cst|tr|St|tdtfr$|Si}t|D]^}z||Wq0ttfk r}z(td|| D]\}}|||<qjW5d}~XYq0Xq0|SdS)rNz_cnfmerge: fallback due to:) rdicttyperrupdateAttributeError TypeErrorprintitems)Zcnfscnfcmsgkvr r r _cnfmergees   r+Tc Csz||}t|drtdt|}i}t||D]@\}}t|}|r`|ddkr`|dd}|rl||}|||<q4|S)aReturn a properly formatted dict built from Tcl list pairs. If cut_minus is True, the supposed '-' prefix will be removed from keys. If conv is specified, it is used to convert values. Tcl list is expected to contain an even number of elements. zNTcl list representing a dict is expected to contain an even number of elementsr-rN) splitlistr RuntimeErroriterzipr) tkr*Z cut_minusconvtitrkeyr r r r _splitdict{s    r7c@seZdZdZeZdZdZeZdZdZ dZ dZ dZ d Z d Zd Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#d Z$d!Z%d"Z&d#Z'd$Z(d%Z)e*j+Z+d&S)' EventType23456789Z10Z11Z12Z13Z14Z15Z16Z17Z18Z19Z20Z21Z22Z23Z24Z25Z26Z27Z28Z29Z30Z31Z32Z33Z34Z35Z36Z37Z38N),__name__ __module__ __qualname__ZKeyPressZKeyZ KeyReleaseZ ButtonPressButtonZ ButtonReleaseZMotionZEnterZLeaveZFocusInZFocusOutZKeymapZExposeZGraphicsExposeZNoExposeZ VisibilityZCreateZDestroyZUnmapZMapZ MapRequestZReparentZ ConfigureZConfigureRequestZGravityZ ResizeRequestZ CirculateZCirculateRequestZPropertyZSelectionClearZSelectionRequestZ SelectionZColormapZ ClientMessageMappingZ VirtualEventZActivateZ DeactivateZ MouseWheelr__str__r r r r r8sPr8c@seZdZdZddZdS)EventaContainer for the properties of an event. Instances of this type are generated if one of the following events occurs: KeyPress, KeyRelease - for keyboard events ButtonPress, ButtonRelease, Motion, Enter, Leave, MouseWheel - for mouse events Visibility, Unmap, Map, Expose, FocusIn, FocusOut, Circulate, Colormap, Gravity, Reparent, Property, Destroy, Activate, Deactivate - for window events. If a callback function for one of these events is registered using bind, bind_all, bind_class, or tag_bind, the callback is called with an Event as first argument. It will have the following attributes (in braces are the event types for which the attribute is valid): serial - serial number of event num - mouse button pressed (ButtonPress, ButtonRelease) focus - whether the window has the focus (Enter, Leave) height - height of the exposed window (Configure, Expose) width - width of the exposed window (Configure, Expose) keycode - keycode of the pressed key (KeyPress, KeyRelease) state - state of the event as a number (ButtonPress, ButtonRelease, Enter, KeyPress, KeyRelease, Leave, Motion) state - state as a string (Visibility) time - when the event occurred x - x-position of the mouse y - y-position of the mouse x_root - x-position of the mouse on the screen (ButtonPress, ButtonRelease, KeyPress, KeyRelease, Motion) y_root - y-position of the mouse on the screen (ButtonPress, ButtonRelease, KeyPress, KeyRelease, Motion) char - pressed character (KeyPress, KeyRelease) send_event - see X/Windows documentation keysym - keysym of the event as a string (KeyPress, KeyRelease) keysym_num - keysym of the event as a number (KeyPress, KeyRelease) type - type of the event as a number widget - widget in which the event occurred delta - delta of wheel movement (MouseWheel) csdd|jD|js"d=n|jdkr:t|jd<t|ddsLd=|jdkr^d=n|t|jtr|j}d }g}t|D]\}}|d |>@r| |q|d t |>d @}|s|s| t |d |d<|j dkrd =d }dt|jd|jd fdd|DfS)NcSsi|]\}}|dkr||qS)??r .0r)r*r r r sz"Event.__repr__..charrH send_eventTrstate) ZShiftZLockZControlZMod1ZMod2ZMod3ZMod4ZMod5ZButton1ZButton2ZButton3ZButton4ZButton5r|delta) rMrNkeysymkeycoderLnumrPfocusxywidthheightz <%s event%s>namec3s&|]}|krd||fVqdS)z %s=%sNr )rJr)attrsr r sz!Event.__repr__..)__dict__r%rLreprgetattrrNrint enumerateappendrhexrrPr )selfrNZmodssinkeysr r[r __repr__s6       zEvent.__repr__N)rArBrC__doc__rjr r r r rGs*rGcCsdadabdS)zInhibit setting of default root window. Call this function to inhibit that the first instance of Tk is used for windows without an explicit parent window. FN)_support_default_root _default_rootr r r r NoDefaultRootsrncCs:ts tdts6|r$td|dt}t|ks6ttS)NzINo master specified and tkinter is configured to not support default rootz Too early to z: no default root window)rlr/rmTkAssertionError)whatrootr r r _get_default_root#s rscCsdSrNr )errr r r _tkerror/srvcCs.z t|}Wntk r YnXt|dS)zBInternal function. Calling it will raise the exception SystemExit.N)ra ValueError SystemExit)coder r r _exit4s  rzc@seZdZdZdZdZdZdddZddZdd Z d d Z e Z d d Z ddZ ddZddZddZddZeZddZddZddZdS)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().rZNcCs|dk rt|tstd|s&td}||_|j|_|rD||_ndtt |_t d7a |dk rn| |n&|j |j dd|js| |j dS)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 stringzcreate variablePY_VARrinfoexists)rrr#rs_rootr2_tk_namer__varnum initialize getbooleancall_defaultremasterr rYr r r __init__Is   zVariable.__init__cCsb|jdkrdS|j|jdd|jr6|j|j|jdk r^|jD]}|j|qFd|_dS)zUnset the variable in Tcl.Nr}r~)rrrrZglobalunsetvar _tclCommands deletecommandrerYr r r __del__gs   zVariable.__del__cCs|jS)z'Return the name of the variable in Tcl.)rrer r r rFsszVariable.__str__cCs|j|j|SzSet the variable to VALUE.)r globalsetvarrrer r r r setwsz Variable.setcCs|j|jS)zReturn value of variable.)r globalgetvarrrr r r get}sz Variable.getcCst|d|jj}tt|}z |j}Wntk r:YnXz||j}Wntk r^YnX|j |||j dkr~g|_ |j ||SN) CallWrapperr__call__r_id__func__r"rAr createcommandrrc)recallbackfcbnamer r r _registers    zVariable._registercCs(||}|jddd|j||f|S)a#Define a trace callback for the variable. Mode is one of "read", "write", "unset", or a list or tuple of such strings. Callback must be a function which is called when the variable is read, written or unset. Return the name of the callback. traceaddvariablerrrrremoderrr r r trace_adds  zVariable.trace_addcCsx|jddd|j|||D] \}}|j|d|kr qtq |j|z|j|Wntk rrYnXdS)aDelete the trace callback for a variable. Mode is one of "read", "write", "unset" or a list or tuple of such strings. Must be same as were specified in trace_add(). cbname is the name of the callback returned from trace_add(). rremoverrN) rrr trace_infor.rrrrwrerrmZcar r r trace_removes  zVariable.trace_removec s4|jjfddt|jddd|jDS)z&Return all trace callback information.csg|]\}}||fqSr r rIr.r r sz'Variable.trace_info..rr}r)rr.rrrrr rr rszVariable.trace_infocCs$||}|jdd|j|||S)aDefine 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. This deprecated method wraps a deprecated Tcl method that will likely be removed in the future. Use trace_add() instead. rrrrr r r trace_variables zVariable.trace_variablecCs|jdd|j|||j|d}|D] \}}|j|d|kr.qq.|j|z|j|Wntk rYnXdS)aSDelete 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. This deprecated method wraps a deprecated Tcl method that will likely be removed in the future. Use trace_remove() instead. rZvdeleterN) rrrr.rrrrrwrr r r trace_vdeletes  zVariable.trace_vdeletecs(fddjjddjDS)zReturn all trace callback information. This deprecated method wraps a deprecated Tcl method that will likely be removed in the future. Use trace_info() instead. csg|]}j|qSr )rr.rJrUrr r rsz(Variable.trace_vinfo..rZvinfo)rr.rrrr rr trace_vinfoszVariable.trace_vinfocCs6t|tstS|j|jko4|jj|jjko4|j|jkSr)rr{NotImplementedr __class__rAr)reotherr r r __eq__s   zVariable.__eq__)NNN)rArBrCrkrrrrrrFrrrrrrrrrrrrr r r r r{@s&   r{c@s&eZdZdZdZdddZddZdS) StringVarz#Value holder for strings variables.rZNcCst||||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. Nr{rrr r r rs zStringVar.__init__cCs$|j|j}t|tr|St|S)z#Return value of variable as string.)rrrrrrr r r rs z StringVar.get)NNNrArBrCrkrrrr r r r rs rc@s&eZdZdZdZdddZddZdS) IntVarz#Value holder for integer variables.rNcCst||||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. Nrrr r r rs zIntVar.__init__c CsJ|j|j}z|j|WSttfk rDt|j|YSXdS)z/Return the value of the variable as an integer.N)rrrgetintr#TclErrorra getdoublerr r r rs z IntVar.get)NNNrr r r r r s rc@s&eZdZdZdZdddZddZdS) DoubleVarz!Value holder for float variables.gNcCst||||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. Nrrr r r r*s zDoubleVar.__init__cCs|j|j|jS)z,Return the value of the variable as a float.)rrrrrr r r r6sz DoubleVar.get)NNNrr r r r r&s rc@s2eZdZdZdZd ddZddZeZdd ZdS) BooleanVarz#Value holder for boolean variables.FNcCst||||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. Nrrr r r r?s zBooleanVar.__init__cCs|j|j|j|Sr)rrrrrr r r rKszBooleanVar.setcCs:z|j|j|jWStk r4tdYnXdS)z+Return the value of the variable as a bool. invalid literal for getboolean()N)rrrrrrwrr r r rQszBooleanVar.get)NNN) rArBrCrkrrrrrr r r r r;s  rcCstdj|dS)zRun the main loop of Tcl.zrun the main loopN)rsr2mainloop)rhr r r rYsrcCs4ztdj|WStk r.tdYnXdS)z$Convert Tcl object to True or False.zuse getboolean()rN)rsr2rrrwrfr r r rcsrc@seZdZdZdZdZddZddZd1ddZd d Z d d Z d2ddZ e Z d3ddZ d4ddZd5ddZd6ddZddZddZddZdd ZeZd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd7d/d0Zd1d2Zd3d4Zd8d6d7Z d8d9Z!d:d;Z"dd?Z$d@dAZ%dBdCZ&dDdEZ'dFdGZ(d9dHdIZ)dJdKZ*dLdMZ+d:dNdOZ,dPdQZ-dRdSZ.dTdUZ/dVdWZ0dXdYZ1dZd[Z2d;d\d]Z3ddbdcZ7dddeZ8dfdgZ9dhdiZ:djdkZ;d?dldmZdrdsZ?dtduZ@dvdwZAdxdyZBd@dzd{ZCd|d}ZDd~dZEddZFddZGdAddZHddZIddZJddZKddZLddZMddZNddZOddZPddZQddZRddZSddZTddZUddZVddZWddZXddZYddZZddZ[ddZ\ddZ]ddZ^dBddZ_ddZ`ddZaddZbddZcddZdddZedd„ZfddĄZgddƄZhddȄZiddʄZjdCdd̄ZkdDddτZldEddфZmdFddӄZndGddՄZoddׄZpdHddلZqddۄZrdIdd݄Zsdd߄ZtddZuddZvddZwddZxeyddZzdJddZ{ddZ|e|Z}dKddZ~e~ZddZdZdeZddZddZddZddZddZdLddZeZddZeZddZddZddZdd Zd gZefd d ZeZd dZeZddZdMddZeZdNddZeZddZddZifddZeZddZefddZifdd ZeZd!d"ZeZdOd#d$Zd%d&Zd'd(Zd)d*ZdPd+d,Zd-d.Zd/d0ZdS(QMisczRInternal class. Base class which defines methods common for interior widgets.NcCs,|jdk r(|jD]}|j|qd|_dS)zkInternal function. Delete all Tcl commands created for this widget in the Tcl interpreter.N)rr2rrr r r destroyxs  z Misc.destroycCs6|j|z|j|Wntk r0YnXdS)zDInternal function. Delete the Tcl command provided in NAME.N)r2rrrrwrr r r rs  zMisc.deletecommandcCs|j|jdd|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.rtk_strictMotif)r2rrrebooleanr r r rs  zMisc.tk_strictMotifcCs|jddS)zDChange the color scheme to light brown as used in Tk 3.6 and before. tk_bisqueNr2rrr r r rszMisc.tk_bisquecOs(|jdt|tt|dS)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)r2rrrr%reargskwr r r rs zMisc.tk_setPaletter|cCs|jdd|dS)zWait until the variable is modified. A parameter of type IntVar, StringVar, DoubleVar or BooleanVar must be given.tkwaitrNrrr r r wait_variableszMisc.wait_variablecCs"|dkr |}|jdd|jdS)zQWait until a WIDGET is destroyed. If no parameter is given self is used.Nrwindowr2r_wrerr r r wait_windowszMisc.wait_windowcCs"|dkr |}|jdd|jdS)zxWait until the visibility of a WIDGET changes (e.g. it appears). If no parameter is given self is used.NrZ visibilityrrr r r wait_visibilityszMisc.wait_visibility1cCs|j||dS)zSet Tcl variable NAME to VALUE.N)r2setvar)rerYr r r r rsz Misc.setvarcCs |j|S)z"Return value of Tcl variable NAME.)r2getvarrr r r rsz Misc.getvarc CsBz|j|WStk r<}ztt|W5d}~XYnXdSr)r2rrrwrrerfexcr r r rsz Misc.getintc CsBz|j|WStk r<}ztt|W5d}~XYnXdSr)r2rrrwrrr r r rszMisc.getdoublecCs0z|j|WStk r*tdYnXdS)zPReturn a boolean value for Tcl boolean values true and false given as parameter.rN)r2rrrw)rerfr r r rszMisc.getbooleancCs|jd|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.rTNrrr r r focus_setszMisc.focus_setcCs|jdd|jdS)ztDirect input focus to this widget even if the application does not have the focus. Use with caution!rTz-forceNrrr r r focus_forceszMisc.focus_forcecCs&|jd}|dks|sdS||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.rTnoneN)r2r _nametowidgetrr r r focus_gets  zMisc.focus_getcCs,|jdd|j}|dks|s"dS||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.rT -displayofrNr2rrrrr r r focus_displayofs zMisc.focus_displayofcCs,|jdd|j}|dks|s"dS||S)zyReturn the widget which would have the focus if top level for this widget gets the focus from the window manager.rTz-lastforrNrrr r r focus_lastfors zMisc.focus_lastforcCs|jddS)zXThe widget under mouse will get automatically focus. Can not be disabled easily.tk_focusFollowsMouseNrrr r r rszMisc.tk_focusFollowsMousecCs"|jd|j}|sdS||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_focusNextNrrr r r r s zMisc.tk_focusNextcCs"|jd|j}|sdS||S)zHReturn previous widget in the focus order. See tk_focusNext for details. tk_focusPrevNrrr r r rszMisc.tk_focusPrevcsNsjd|dSfdd}j|_|jd|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.afterNcs8z W5zWntk r0YnXXdSr)rrr rfuncrYrer r callit,s  zMisc.after..callit)r2rrAr)reZmsrrrr rr r s z Misc.aftercGs|jd|f|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)rerrr r r after_idle8szMisc.after_idlecCsd|s tdz.|jdd|}|j|d}||Wntk rNYnX|jdd|dS)zCancel scheduling of function identified with ID. Identifier returned by after or after_idle must be given as first parameter. z?id must be a valid identifier returned from after or after_idlerr}rZcancelN)rwr2rr.rr)rerdataZscriptr r r after_cancel@szMisc.after_cancelrcCs|jd||dS)zRing a display's bell.)bellN)r2r _displayofre displayofr r r rQsz Misc.bellcKsdd|krN|jdkrNz d|d<|jd||WStk rL|d=YnX|jd||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) r x11 UTF8_STRING) clipboardr)_windowingsystemr2r_optionsrrerr r r clipboard_getVs zMisc.clipboard_getcKs,d|kr|j|d<|jd||dS)zClear the data in the Tk clipboard. A widget specified for the optional displayof keyword argument specifies the target display.r)rclearNrr2rrrr r r clipboard_clearms zMisc.clipboard_clearcKs4d|kr|j|d<|jd||d|fdS)zAppend STRING to the Tk clipboard. A widget specified at the optional displayof keyword argument specifies the target display. The clipboard can be retrieved with selection_get.r)rrc--Nr)restringrr r r clipboard_appendus  zMisc.clipboard_appendcCs$|jdd|j}|sdS||S)zOReturn widget which has currently the grab in this application or None.grabZcurrentNrrr r r grab_currentszMisc.grab_currentcCs|jdd|jdS)z.Release grab for this widget if currently set.rreleaseNrrr r r grab_releaseszMisc.grab_releasecCs|jdd|jdS)zwSet grab for this widget. A grab directs all events to this and descendant widgets in the application.rrNrrr r r grab_setsz Misc.grab_setcCs|jddd|jdS)zSet global grab for this widget. A global grab directs all events to this and descendant widgets on the display. Use with caution - other applications do not get events anymore.rrz-globalNrrr r r grab_set_globalszMisc.grab_set_globalcCs"|jdd|j}|dkrd}|S)zYReturn None, "local" or "global" if this widget has no, a local or a global grab.rstatusrNr)rerr r r grab_statusszMisc.grab_statuscCs|jdd|||dS)zSet a VALUE (second parameter) for an option PATTERN (first parameter). An optional third parameter gives the numeric priority (defaults to 80).optionrNr)repatternr priorityr r r option_addszMisc.option_addcCs|jdddS)zPClear the option database. It will be reloaded if option_add is called.rrNrrr r r option_clearszMisc.option_clearcCs|jdd|j||S)zReturn the value for an option NAME for this widget with CLASSNAME. Values with higher priority override lower values.rrr)rerY classNamer r r option_getszMisc.option_getcCs|jdd||dS)zvRead file FILENAME into the option database. An optional second parameter gives the numeric priority.rZreadfileNr)reZfileNamerr r r option_readfileszMisc.option_readfilecKs,d|kr|j|d<|jd||dS)zClear the current X selection.r) selectionrNrrr r r selection_clears zMisc.selection_clearcKsvd|kr|j|d<d|kr`|jdkr`z d|d<|jd||WStk r^|d=YnX|jd||S)aReturn the contents of the current X selection. A keyword parameter selection specifies the name of the selection and defaults to PRIMARY. A keyword parameter displayof specifies a widget on the display to use. A keyword parameter type specifies the form of data to be fetched, defaulting to STRING except on X11, where UTF8_STRING is tried before STRING.rr rr)r r)rrr2rrrrr r r selection_gets   zMisc.selection_getcKs.||}|jd|||j|fdS)aSpecify a function COMMAND to call if the X selection owned by this widget is queried by another application. This function must return the contents of the selection. The function will be called with the arguments OFFSET and LENGTH which allows the chunking of very long selections. The following keyword parameters can be provided: selection - name of the selection (default PRIMARY), type - type of the selection (e.g. STRING, FILE_NAME).)r ZhandleN)rr2rrr)recommandrrYr r r selection_handles zMisc.selection_handlecKs"|jd|||jfdS)zBecome owner of X selection. A keyword parameter selection specifies the name of the selection (default PRIMARY).r ZownN)r2rrrrr r r selection_owns zMisc.selection_owncKs:d|kr|j|d<|jd||}|s0dS||S)zReturn owner of X selection. The following keyword parameter can be provided: selection - name of the selection (default PRIMARY), type - type of the selection (e.g. STRING, FILE_NAME).rrN)rr2rrr)rerrYr r r selection_own_gets  zMisc.selection_own_getcGs|jd||f|S)zDSend Tcl command CMD to different interpreter INTERP to be executed.sendr)reZinterpcmdrr r r rsz Misc.sendcCs|jd|j|dS)z(Lower this widget in the stacking order.lowerNr)re belowThisr r r rsz Misc.lowercCs|jd|j|dS)z(Raise this widget in the stacking order.raiseNr)re aboveThisr r r tkraisesz Misc.tkraisecCs(d|||f}|j|j|S)z*Return integer which represents atom NAME.)winfoZatom)rr2rr)rerYrrr r r winfo_atomszMisc.winfo_atomcCs d|||f}|j|S)z'Return name of atom with identifier ID.)rZatomnamerr2rrerrrr r r winfo_atomname s zMisc.winfo_atomnamecCs|j|jdd|jS)z7Return number of cells in the colormap for this widget.rZcellsr2rrrrr r r winfo_cellsszMisc.winfo_cellsc CsRg}|j|jdd|jD].}z|||Wqtk rJYqXq|S)z?Return a list of all widgets which are children of this widget.rchildren)r2r.rrrcrKeyError)reresultchildr r r winfo_childrenszMisc.winfo_childrencCs|jdd|jS)z(Return window class name of this widget.rclassrrr r r winfo_class#szMisc.winfo_classcCs|j|jdd|jS)z?Return True if at the last color request the colormap was full.rZ colormapfullr2rrrrr r r winfo_colormapfull'szMisc.winfo_colormapfullcCs4d||||f}|j|}|s*dS||S)z@Return the widget which is at the root coordinates ROOTX, ROOTY.)rZ containingN)rr2rr)reZrootXZrootYrrrYr r r winfo_containing,s zMisc.winfo_containingcCs|j|jdd|jS)z$Return the number of bits per pixel.rZdepthr!rr r r winfo_depth4szMisc.winfo_depthcCs|j|jdd|jS)z"Return true if this widget exists.rr~r!rr r r winfo_exists8szMisc.winfo_existscCs|j|jdd|j|S)zWReturn the number of pixels for the given distance NUMBER (e.g. "3c") as float.rZfpixelsr2rrrrenumberr r r winfo_fpixels=s  zMisc.winfo_fpixelscCs|jdd|jS)zFReturn geometry string for this widget in the form "widthxheight+X+Y".rgeometryrrr r r winfo_geometryCszMisc.winfo_geometrycCs|j|jdd|jS)zReturn height of this widget.rrXr!rr r r winfo_heightGszMisc.winfo_heightcCst|jdd|jdS)z%Return identifier ID for this widget.rrr)rar2rrrr r r winfo_idLsz Misc.winfo_idcCs"d||}|j|j|S)z9Return the name of all Tcl interpreters for this display.)rZinterps)rr2r.r)rerrr r r winfo_interpsPszMisc.winfo_interpscCs|j|jdd|jS)z%Return true if this widget is mapped.rZismappedr!rr r r winfo_ismappedUszMisc.winfo_ismappedcCs|jdd|jS)z/Return the window manager name for this widget.rZmanagerrrr r r winfo_managerZszMisc.winfo_managercCs|jdd|jS)zReturn the name of this widget.rrYrrr r r winfo_name^szMisc.winfo_namecCs|jdd|jS)z-Return the name of the parent of this widget.rparentrrr r r winfo_parentbszMisc.winfo_parentcCs d|||f}|j|S)z.Return the pathname of the widget given by ID.)rpathnamerrr r r winfo_pathnamefs zMisc.winfo_pathnamecCs|j|jdd|j|S)z'Rounded integer value of winfo_fpixels.rZpixelsr!r0r r r winfo_pixelslszMisc.winfo_pixelscCs|j|jdd|jS)z:Return the x coordinate of the pointer on the root window.rZpointerxr!rr r r winfo_pointerxqszMisc.winfo_pointerxcCs||jdd|jS)zHReturn a tuple of x and y coordinates of the pointer on the root window.rZ pointerxy_getintsr2rrrr r r winfo_pointerxyvszMisc.winfo_pointerxycCs|j|jdd|jS)z:Return the y coordinate of the pointer on the root window.rZpointeryr!rr r r winfo_pointery{szMisc.winfo_pointerycCs|j|jdd|jS)z'Return requested height of this widget.rZ reqheightr!rr r r winfo_reqheightszMisc.winfo_reqheightcCs|j|jdd|jS)z&Return requested width of this widget.rZreqwidthr!rr r r winfo_reqwidthszMisc.winfo_reqwidthcCs||jdd|j|S)zNReturn a tuple of integer RGB values in range(65536) for color in this widget.rZrgbrA)reZcolorr r r winfo_rgbszMisc.winfo_rgbcCs|j|jdd|jS)zSReturn x coordinate of upper left corner of this widget on the root window.rZrootxr!rr r r winfo_rootxszMisc.winfo_rootxcCs|j|jdd|jS)zSReturn y coordinate of upper left corner of this widget on the root window.rZrootyr!rr r r winfo_rootyszMisc.winfo_rootycCs|jdd|jS)z&Return the screen name of this widget.rscreenrrr r r winfo_screenszMisc.winfo_screencCs|j|jdd|jS)zTReturn the number of the cells in the colormap of the screen of this widget.rZ screencellsr!rr r r winfo_screencellsszMisc.winfo_screencellscCs|j|jdd|jS)z\Return the number of bits per pixel of the root window of the screen of this widget.rZ screendepthr!rr r r winfo_screendepthszMisc.winfo_screendepthcCs|j|jdd|jS)zXReturn the number of pixels of the height of the screen of this widget in pixel.rZ screenheightr!rr r r winfo_screenheightszMisc.winfo_screenheightcCs|j|jdd|jS)zUReturn the number of pixels of the height of the screen of this widget in mm.rZscreenmmheightr!rr r r winfo_screenmmheightszMisc.winfo_screenmmheightcCs|j|jdd|jS)zTReturn the number of pixels of the width of the screen of this widget in mm.rZ screenmmwidthr!rr r r winfo_screenmmwidthszMisc.winfo_screenmmwidthcCs|jdd|jS)zReturn one of the strings directcolor, grayscale, pseudocolor, staticcolor, staticgray, or truecolor for the default colormodel of this screen.rZ screenvisualrrr r r winfo_screenvisualszMisc.winfo_screenvisualcCs|j|jdd|jS)zWReturn the number of pixels of the width of the screen of this widget in pixel.rZ screenwidthr!rr r r winfo_screenwidthszMisc.winfo_screenwidthcCs|jdd|jS)zxReturn information of the X-Server of the screen of this widget in the form "XmajorRminor vendor vendorVersion".rZserverrrr r r winfo_serverszMisc.winfo_servercCs||jdd|jS)z*Return the toplevel widget of this widget.rtoplevel)rr2rrrr r r winfo_toplevels  zMisc.winfo_toplevelcCs|j|jdd|jS)zBReturn true if the widget and all its higher ancestors are mapped.rZviewabler!rr r r winfo_viewableszMisc.winfo_viewablecCs|jdd|jS)zReturn one of the strings directcolor, grayscale, pseudocolor, staticcolor, staticgray, or truecolor for the colormodel of this widget.rvisualrrr r r winfo_visualszMisc.winfo_visualcCs|jdd|jS)z7Return the X identifier for the visual for this widget.rZvisualidrrr r r winfo_visualidszMisc.winfo_visualidFcsHjddj|rdnd}fddj|D}fdd|DS)zReturn a list of all visuals available for the screen of this widget. Each item in the list consists of a visual name (see winfo_visual), a depth and if includeids is true is given also the X identifier.rZvisualsavailable includeidsNcsg|]}j|qSr )r2r.rrr r rsz/Misc.winfo_visualsavailable..csg|]}|qSr )_Misc__winfo_parseitemrrr r rs)r2rrr.)rerZrr rr winfo_visualsavailables  zMisc.winfo_visualsavailablecCs$|ddtt|j|ddS)rNr)rr_Misc__winfo_getint)rer4r r r Z__winfo_parseitemszMisc.__winfo_parseitemcCs t|dS)rr)rarerUr r r Z__winfo_getintszMisc.__winfo_getintcCs|j|jdd|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 vrootheightr!rr r r winfo_vrootheightszMisc.winfo_vrootheightcCs|j|jdd|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 vrootwidthr!rr r r winfo_vrootwidthszMisc.winfo_vrootwidthcCs|j|jdd|jS)ziReturn the x offset of the virtual root relative to the root window of the screen of this widget.rZvrootxr!rr r r winfo_vrootxszMisc.winfo_vrootxcCs|j|jdd|jS)ziReturn the y offset of the virtual root relative to the root window of the screen of this widget.rZvrootyr!rr r r winfo_vrooty szMisc.winfo_vrootycCs|j|jdd|jS)z Return the width of this widget.rrWr!rr r r winfo_widthszMisc.winfo_widthcCs|j|jdd|jS)zVReturn the x coordinate of the upper left corner of this widget in the parent.rrUr!rr r r winfo_xsz Misc.winfo_xcCs|j|jdd|jS)zVReturn the y coordinate of the upper left corner of this widget in the parent.rrVr!rr r r winfo_ysz Misc.winfo_ycCs|jddS)zEEnter event loop until all pending events have been processed by Tcl.r!Nrrr r r r! sz Misc.updatecCs|jdddS)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.r!Z idletasksNrrr r r update_idletasks$szMisc.update_idletaskscCs6|dkr |j|jd|jS|jd|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).Nbindtagsr2r.rr)reZtagListr r r rg*s z Misc.bindtagsrcCst|tr |j|||fnn|rd|||j|}d|r>dp@d||jf}|j|||f|S|rz|j||fS|j|j|SdS)rz"%sif {"[%s %s]" == "break"} break +rZN)rrr2rr _substitute_subst_format_strr.)rerqsequencerr needcleanupfuncidrr r r _bind7s"   z Misc._bindcCs|d|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.bindrorrerlrrr r r rpIs'z Misc.bindcCs&|jd|j|d|r"||dS)zWUnbind for this widget for event SEQUENCE the function identified with FUNCID.rprZNr2rrr)rerlrnr r r unbindrsz Misc.unbindcCs|d|||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.)rpallrrorrr r r bind_allysz Misc.bind_allcCs|jdd|ddS)z8Unbind for all widgets for event SEQUENCE all functions.rprurZNr)rerlr r r unbind_allszMisc.unbind_allcCs|d|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.rprrv)rer rlrrr r r bind_classszMisc.bind_classcCs|jd||ddS)zWUnbind for all widgets with bindtag CLASSNAME for event SEQUENCE all functions.rprZNr)rer rlr r r unbind_classszMisc.unbind_classcCs|j|dS)zCall the mainloop of Tk.N)r2r)rerhr r r rsz Misc.mainloopcCs|jdS)z8Quit the Tcl interpreter. All widgets will be destroyed.N)r2quitrr r r r{sz Misc.quitcCs"|rtt|jj|j|SdSrt)rrr2rr.rerr r r rBsz Misc._getintscCs"|rtt|jj|j|SdSrt)rrr2rr.r|r r r _getdoublesszMisc._getdoublescCs|r|j|SdSrt)r2rr|r r r _getbooleanszMisc._getbooleancCs"|r d|fS|dkrd|jfSdS)rrNr rrr r r rs  zMisc._displayofcCsBz |jWStk r<|jdd}|_|YSXdS)rr2ZwindowingsystemN)rZ_windowingsystem_cachedr"r2r)reZwsr r r rs   zMisc._windowingsystemcCs|rt||f}nt|}d}|D]\}}|dk r&|ddkrN|dd}t|rb||}n^t|ttfrg}|D]<}t|tr|t |qxt|t r|t |qxqqxd |}|d||f}q&|S)rr N_rr-) r+r%callablerrrrrarcrrr)rer&rrr)r*Znvrr r r rs*     z Misc._optionscCsNt|d}|}|ds.|}|dd}|D]}|s>qJ|j|}q2|S)zPReturn the Tkinter instance of a widget identified by its Tcl name NAME..rrN)rsplitrr#)rerYwrhr r r nametowidgets  zMisc.nametowidgetcCst|||j}tt|}z |j}Wntk r8YnXz||j}Wntk r\YnX|j|||r|j dkrg|_ |j ||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) rrr_rrr"rAr2rrrc)rersubstrmrrYr r r rs     zMisc._registercCs|}|jr|j}q|S)rr)rerr r r rsz Misc._root)z%#z%bz%fz%hz%kz%sz%tz%wz%xz%yz%Az%Ez%Kz%Nz%Wz%Tz%Xz%Yz%Drcst|t|jkr|S|jj}|jjfdd}|\}}}}}} } } } } }}}}}}}}}t}||_|||_z|||_Wnt k rYnX|||_ |||_ || |_ || |_ || |_|| |_|| |_||_z|||_Wnt k r YnX||_|||_zt||_Wntk rF||_YnXz|||_Wntk rt||_YnX|||_|||_z||_Wn tt fk rd|_YnX|fS)rc s,z |WSttfk r&|YSXdS)z?Tk changed behavior in 8.4.2, returning "??" rather more often.N)rwrrrr r getint_events z&Misc._substitute..getint_eventr)r _subst_formatr2rrrGserialrSrTrrXrRrNtimerWrUrVrLrMrQZ keysym_numr8r rwrwidgetr$Zx_rootZy_rootrP)rerrrZnsignbrhr)rfr4rrUrVAEKNWTXYDer rr rj sT *               zMisc._substitutecCs(t\}}}|}||||dSrt)sysexc_inforreport_callback_exception)rervaltbrrr r r _report_exceptionHszMisc._report_exceptioncGs\i}|j|jj|D]>}|j|}|dddf|dd||ddd<q|S)z;Call Tcl configure command and return the result as a dict.rrNr2r.r)rerr&rUr r r _getconfigureNs  0zMisc._getconfigurecGs2|j|jj|}|dddf|ddS)Nrrr)rerrUr r r _getconfigure1VszMisc._getconfigure1cCs|rt||f}n |rt|}|dkr:|t|j|fSt|tr^|t|j|d|fS|jt|j|f| |dS)rNr-) r+rrrrrrr2rr)rerr&rr r r _configureZs zMisc._configurecKs|d||S)zConfigure resources of a widget. The values for resources are specified as keyword arguments. To get an overview about the allowed keyword arguments call the method keys. configurerrer&rr r r rgszMisc.configurecCs|j|jdd|S)z4Return the resource value for a KEY given as string.cgetr-rrer6r r r rrsz Misc.cgetcCs|||idSr)rrer6r r r r __setitem__xszMisc.__setitem__cs*|jjfdd|j|jdDS)z3Return a list of all resource names of this widget.cs g|]}|dddqS)rrNr rrr r r~szMisc.keys..rrhrr rr ri{s z Misc.keyscCs|jS)z+Return the window path name of this widget.rrr r r rFsz Misc.__str__cCsd|jj|jj|jfS)Nz<%s.%s object %s>)rrBrCrrr r r rjs z Misc.__repr___noarg_cCs:|tjkr"||jdd|jS|jdd|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 propagateNrrr~r2rrreflagr r r pack_propagates  zMisc.pack_propagatecs(fddjjddjDS)HReturn a list of all slaves of this widget in its packing order.csg|]}|qSr rrrr r rsz$Misc.pack_slaves..rslavesrhrr rr pack_slavess  zMisc.pack_slavescs(fddjjddjDS)rcsg|]}|qSr rrrr r rsz%Misc.place_slaves..placerrhrr rr place_slavess zMisc.place_slavescCs|jdd|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.gridanchorNr)rerr r r grid_anchorszMisc.grid_anchorcCsZdd|jf}|dk r(|dk r(|||f}|dk rD|dk rD|||f}||jj|pXdS)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. rbboxN)rrBr2r)recolumnrowZcol2Zrow2rr r r grid_bboxs   zMisc.grid_bboxc Csht|ttjfrdz:t|}|s$WdSd|kr:|j|WS|j|WSWnttfk rbYnX|S)Nr) rr_tkinterZTcl_Objr2rrrwr)rer Zsvaluer r r _gridconvvalueszMisc._gridconvvaluecCst|trJ|sJ|dddkr*|dd}|dddkrBd|}|f}n |||}|s|t|j|jd||j||jdS|jd||j|f|}t|dkr||SdS)rrNrrr-r)r3) rrrr7r2rrrr)rerindexr&roptionsrr r r _grid_configures(    zMisc._grid_configurecKs|d|||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).columnconfigurerrerr&rr r r grid_columnconfigureszMisc.grid_columnconfigurec Cs ||jdd|j||pdS)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.rlocationNrArerUrVr r r grid_locationszMisc.grid_locationcCs:|tjkr"||jdd|jS|jdd|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. rrNrrr r r grid_propagates  zMisc.grid_propagatecKs|d|||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). rowconfigurerrr r r grid_rowconfigureszMisc.grid_rowconfigurecCs||jdd|jpdS)z.rrrh)rerrrr rr grid_slaves s    zMisc.grid_slavescGsdd|f|}|j|dS)zBind a virtual event VIRTUAL (of the form <>) to an event SEQUENCE such that the virtual event is triggered whenever SEQUENCE occurs.eventrNrrevirtual sequencesrr r r event_add/szMisc.event_addcGsdd|f|}|j|dS)z-Unbind a virtual event VIRTUAL from SEQUENCE.rdeleteNrrr r r event_delete6szMisc.event_deletecKsDdd|j|f}|D]\}}|d|t|f}q|j|dS)zGenerate an event SEQUENCE. Additional keyword arguments specify parameter of the event (e.g. x, y, rootx, rooty).rZgenerate-%sN)rr%rr2r)rerlrrr)r*r r r event_generate;szMisc.event_generatecCs|j|jdd|S)zuReturn a list of all virtual events or the information about the SEQUENCE bound to the virtual event VIRTUAL.rr}r)rerr r r event_infoDszMisc.event_infocCs|j|jddS)z*Return a list of all existing image names.imagenamesrrr r r image_namesLszMisc.image_namescCs|j|jddS)z?Return a list of all available image types (e.g. photo bitmap).rtypesrrr r r image_typesPszMisc.image_types)N)r|)N)N)r|r)r|)N)r)N)N)N)N)r)r)r)r)r)F)N)r)NNN)N)NNN)NNN)r)N)Nr)N)N)NNNN)NN)N)rArBrCrk_last_child_idsrrrrrrrZwaitvarrrrrrrrrrTrrrrrrrrrrrrrrrrrrrrr r r rrrrrrrrliftrr r"r'r)r+r,r-r.r2r4r5r6r7r8r9r:r<r>r?r@rCrDrErFrGrHrIrKrLrMrNrOrPrQrRrSrUrVrXrYr\r[r]r_r`rarbrcrdrer!rfrgrorprtrwrxryrzrr{rBr}r~rpropertyrrrrrregisterrrrrkrjrrrrrconfigr __getitem__rrirFrjrrrrrrrrrrrrrrrrrrrrrrrrrrrr r r r rmsP                          )       =                  rc@s eZdZdZddZddZdS)rzwInternal 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)rrr)rerrrr r r rYszCallWrapper.__init__cGsLz|jr|j|}|j|WStk r2Yn|jYnXdS)z3Apply first function SUBST to arguments, than FUNC.N)rrrxrrrerr r r r_s  zCallWrapper.__call__NrArBrCrkrrr r r r rUsrc@s(eZdZdZddZddZddZdS) XViewzXMix-in class for querying and changing the horizontal position of a widget's window.cGs(|jj|jdf|}|s$||SdS)z5Query and change the horizontal position of the view.xviewNr2rrr}rerrr r r rosz XView.xviewcCs|j|jdd|dS)zsAdjusts the view in the window so that FRACTION of the total width of the canvas is off-screen to the left.rmovetoNrrefractionr r r xview_movetouszXView.xview_movetocCs|j|jdd||dS)z\Shift the x-view according to NUMBER which is measured in "units" or "pages" (WHAT).rscrollNrrer1rqr r r xview_scrollzszXView.xview_scrollN)rArBrCrkrrrr r r r rksrc@s(eZdZdZddZddZddZdS) YViewzVMix-in class for querying and changing the vertical position of a widget's window.cGs(|jj|jdf|}|s$||SdS)z3Query and change the vertical position of the view.yviewNrrr r r rsz YView.yviewcCs|j|jdd|dS)zsAdjusts the view in the window so that FRACTION of the total height of the canvas is off-screen to the top.rrNrrr r r yview_movetoszYView.yview_movetocCs|j|jdd||dS)z\Shift the y-view according to NUMBER which is measured in "units" or "pages" (WHAT).rrNrrr r r yview_scrollszYView.yview_scrollN)rArBrCrkrrrr r r r rsrc@seZdZdZdBddZeZddZeZdCddZeZ d d Z e Z dDd d Z e Z d dZeZdEddZeZddZeZddZeZdFddZeZdGddZeZdHddZeZdIddZeZddZeZdJdd Z e Z!dKd!d"Z"e"Z#dLd$d%Z$e$Z%dMd&d'Z&e&Z'dNd(d)Z(e(Z)d*d+Z*e*Z+dOd,d-Z,e,Z-dPd.d/Z.e.Z/dQd0d1Z0e0Z1dRd2d3Z2e2Z3dSd4d5Z4e4Z5dTd6d7Z6e6Z7dUd8d9Z8e8Z9dVd:d;Z:e:Z;dWdd?Z>e>Z?d@dAZ@e@ZAdS)YWmzAProvides functions for the communication with the window manager.Nc Cs ||jdd|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.wmaspectrA)reZminNumerZminDenomZmaxNumerZmaxDenomr r r wm_aspectsz Wm.wm_aspectcGsdd|jf|}|j|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)rr2rrr r r wm_attributesszWm.wm_attributescCs|jdd|j|S)zVStore NAME in WM_CLIENT_MACHINE property of this widget. Return current value.rclientrrr r r wm_clientsz Wm.wm_clientcsZt|dkr|f}ddjf|}|r4j|n"fddjj|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|]}|qSr rrrr r rsz)Wm.wm_colormapwindows..N)rrr2rr.)reZwlistrr rr wm_colormapwindowss  zWm.wm_colormapwindowscCs|jdd|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.rrrrr r r wm_commandsz Wm.wm_commandcCs|jdd|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 deiconifyrrr r r wm_deiconifyszWm.wm_deiconifycCs|jdd|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 focusmodelr)reZmodelr r r wm_focusmodelszWm.wm_focusmodelcCs|jdd|dS)aAThe window will be unmapped 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.rforgetNrrr r r wm_forgetsz Wm.wm_forgetcCs|jdd|jS)zAReturn identifier for decorative frame of this widget if present.rframerrr r r wm_framesz Wm.wm_framecCs|jdd|j|S)ziSet geometry to NEWGEOMETRY of the form =widthxheight+x+y. Return current value if None is given.rr3r)reZ newGeometryr r r wm_geometryszWm.wm_geometryc Cs ||jdd|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.rrrA)reZ baseWidthZ baseHeightZwidthIncZ heightIncr r r wm_grids z Wm.wm_gridcCs|jdd|j|S)z~Set the group leader widgets for related widgets to PATHNAME. Return the group leader of this widget if None is given.rgrouprreZpathNamer r r wm_group sz Wm.wm_groupcCs2|r|jdd|jd|S|jdd|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 iconbitmap-defaultNr)rebitmapdefaultr r r wm_iconbitmaps zWm.wm_iconbitmapcCs|jdd|jS)zDisplay widget as icon.riconifyrrr r r wm_iconify$sz Wm.wm_iconifycCs|jdd|j|S)zVSet mask for the icon bitmap of this widget. Return the mask if None is given.riconmaskr)rerr r r wm_iconmask*szWm.wm_iconmaskcCs|jdd|j|S)zSSet the name of the icon for this widget. Return the name if None is given.riconnamer)reZnewNamer r r wm_iconname1szWm.wm_iconnameFcGs<|r |jjdd|jdf|n|jjdd|jf|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 simultaneously. On Macintosh, this currently does nothing.r iconphotorNr)rerrr r r wm_iconphoto8szWm.wm_iconphotoc Cs||jdd|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 iconpositionrArr r r wm_iconpositionSs zWm.wm_iconpositioncCs|jdd|j|S)zgSet widget PATHNAME to be displayed instead of icon. Return the current value if None is given.r iconwindowrrr r r wm_iconwindow[szWm.wm_iconwindowcCs|jdd|dS)zThe widget specified will become a stand alone top-level window. The window will be decorated with the window managers title bar, etc.rmanageNr)rerr r r wm_managebsz Wm.wm_managec Cs||jdd|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.rmaxsizerArerWrXr r r wm_maxsizejs z Wm.wm_maxsizec Cs||jdd|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.rminsizerAr$r r r wm_minsizess z Wm.wm_minsizecCs||jdd|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)r~r2rrrr r r wm_overrideredirect|s  zWm.wm_overrideredirectcCs|jdd|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 positionfromrreZwhor r r wm_positionfromszWm.wm_positionfromcCs.t|r||}n|}|jdd|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)rrr2rr)rerYrrr r r wm_protocols zWm.wm_protocolcCs|jdd|j||S)zyInstruct the window manager whether this width can be resized in WIDTH or HEIGHT. Both values are boolean values.r resizablerr$r r r wm_resizableszWm.wm_resizablecCs|jdd|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".rsizefromrr+r r r wm_sizefromszWm.wm_sizefromcCs|jdd|j|S)zQuery or set the state of this widget as one of normal, icon, iconic (see wm_iconwindow), withdrawn, or zoomed (Windows only).rrNr)reZnewstater r r wm_statesz Wm.wm_statecCs|jdd|j|S)zSet the title of this widget.rtitlerr|r r r wm_titlesz Wm.wm_titlecCs|jdd|j|S)z_Instruct the window manager that this widget is transient with regard to widget MASTER.r transientr)rerr r r wm_transientszWm.wm_transientcCs|jdd|jS)zWithdraw this widget from the screen such that it is unmapped and forgotten by the window manager. Re-draw it with wm_deiconify.rwithdrawrrr r r wm_withdrawszWm.wm_withdraw)NNNN)N)N)N)N)NNNN)N)NN)N)N)F)NN)N)NN)NN)N)N)NN)NN)N)N)N)N)BrArBrCrkrrrrrrrrrrrrrrrrr r r r3r rrr rrrrrrrrrrrrr rr"r!r%r#r'r&r)r(r,r*r.r-r0r/r2r1r3rNr5r4r7r6r9r8r r r r rs                        rc@sNeZdZdZdZdddZdd Zd d Zd d ZddZ ddZ ddZ dS)rozzToplevel widget of Tk which represents mostly the main window of an application. It has an associated Tcl interpreter.rNrrc Csd|_i|_d|_d|_|dkrZddl}|jtjd}|j |\}}|dkrZ||}d} t |||| t ||||_|r| tjjs|||dS)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.NFr)z.pyz.pyc)rr# _tkloadedr2ospathbasenamerargvsplitextrcreate wantobjects_loadtkflagsignore_environment readprofile) re screenNamebaseNamer useTksyncZuser;Zext interactiver r r rs z Tk.__init__cCs|js|j|dSr)r:r2loadtkrBrr r r rKs z Tk.loadtkcCsd|_|jd}|tjkr.tdtj|ft|jd}|tjkrZtdtj|f|jdkrjg|_|j dt |j dt |j d|j dt rts|a|d|jdS) NT tk_versionz4tk.h version (%s) doesn't match libtk.a version (%s) tcl_versionz6tcl.h version (%s) doesn't match libtcl.a version (%s)ZtkerrorexitWM_DELETE_WINDOW)r:r2rr TK_VERSIONr/r TCL_VERSIONrrrvrzrcrlrmr-r)rerLrMr r r rBs(      z Tk._loadtkcCsJt|jD] }|q|jd|jt|trFt |krFda dS)zhDestroy this and all descendants widgets. This will end the application of this Tcl interpreter.rN) rr#valuesrr2rrrrlrmrer'r r r r s    z Tk.destroyc Csddl}d|jkr|jd}n|j}|j|d|}|j|d|}|j|d|}|j|d|}d|i} td| |j|r|jd||j|rtt | | |j|r|jd||j|rtt | | dS) 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.pyrezfrom tkinter import *source) r;environcurdirr<rexecisfiler2ropenread) rerGr r;homeZ class_tclZclass_pyZbase_tclZbase_pydirr r r rE s$      zTk.readprofilecCs:ddl}tdtjd|t_|t_|t_||||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 callback)file) tracebackr$rstderr last_type last_valuelast_tracebackprint_exception)rerrrr_r r r r$ s zTk.report_callback_exceptioncCs t|j|S)z3Delegate attribute access to the interpreter object)r`r2)reattrr r r __getattr__0 szTk.__getattr__)NNrorrN) rArBrCrkrrrKrBrrErrfr r r r ros   rocCst||||Sr)ro)rFrGr rHr r r TclC srgc@sTeZdZdZifddZeZZZddZeZ ddZ e Z e j ZZ e jZZdS) PackzQGeometry manager Pack. Base class to use the methods pack_* in every widget.cKs$|jdd|jf|||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. rrNr2rrrrr r r pack_configureL s   zPack.pack_configurecCs|jdd|jdS)z:Unmap this widget and do not use it for the packing order.rrNrrr r r pack_forgetb szPack.pack_forgetcCs8t|j|jdd|j}d|kr4||d|d<|S)zEReturn information about the packing options for this widget.rr}inr7r2rrrredr r r pack_infoh szPack.pack_infoN)rArBrCrkrjrrrrkrrpr}rrrrrr r r r rhG s   rhc@sJeZdZdZifddZeZZZddZeZ ddZ e Z e j ZZ dS) PlacezSGeometry manager Place. Base class to use the methods place_* in every widget.cKs$|jdd|jf|||dS)a Place a widget in the parent widget. Use as options: in=master - master relative to which the widget is placed in_=master - see 'in' option description x=amount - locate anchor of this widget at position x of master y=amount - locate anchor of this widget at position y of master relx=amount - locate anchor of this widget between 0.0 and 1.0 relative to width of master (1.0 is right edge) rely=amount - locate anchor of this widget between 0.0 and 1.0 relative to height of master (1.0 is bottom edge) anchor=NSEW (or subset) - position anchor according to given direction width=amount - width of this widget in pixel height=amount - height of this widget in pixel relwidth=amount - width of this widget between 0.0 and 1.0 relative to width of master (1.0 is the same width as the master) relheight=amount - height of this widget between 0.0 and 1.0 relative to height of master (1.0 is the same height as the master) bordermode="inside" or "outside" - whether to take border width of master widget into account rrNrirr r r place_configurez s   zPlace.place_configurecCs|jdd|jdS)Unmap this widget.rrNrrr r r place_forget szPlace.place_forgetcCs8t|j|jdd|j}d|kr4||d|d<|S)zEReturn information about the placing options for this widget.rr}rlrmrnr r r place_info szPlace.place_infoN)rArBrCrkrrrrrrtrrur}rrrr r r r rqu s  rqc@seZdZdZifddZeZZZej Z Z ej Z Z ddZ e ZddZdd ZeZejZZejZZejZZejZZejZZd S) GridzQGeometry manager Grid. Base class to use the methods grid_* in every widget.cKs$|jdd|jf|||dS)aPosition a widget in the parent widget in a grid. Use as options: column=number - use cell identified with given column (starting with 0) columnspan=number - this widget will span several columns 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 row=number - use cell identified with given row (starting with 0) rowspan=number - this widget will span several rows sticky=NSEW - if cell is larger on which sides will this widget stick to the cell boundary rrNrirr r r grid_configure s   zGrid.grid_configurecCs|jdd|jdS)rsrrNrrr r r grid_forget szGrid.grid_forgetcCs|jdd|jdS)z0Unmap this widget but remember the grid options.rrNrrr r r grid_remove szGrid.grid_removecCs8t|j|jdd|j}d|kr4||d|d<|S)zSReturn information about the options for positioning this widget in a grid.rr}rlrmrnr r r grid_info szGrid.grid_infoN)rArBrCrkrwrrrrrrrrrxrryrzr}rrrrrrrrrrr r r r rv s        rvc@s:eZdZdZddZiidfddZddZd d d Zd S) BaseWidgetzInternal class.cCs|s t}||_|j|_d}d|kr2|d}|d=|s|jj}|jdkrRi|_|j|dd}||j|<|dkrd|f}n d||f}||_|j dkrd||_ n|j d||_ i|_ |j|jj kr|jj |j ||jj |j<dS)z6Internal function. Sets up information about children.NrYrrz!%sz!%s%dr) rsrr2rrArrrrrr#r)rerr&rYcountr r r _setup s2       zBaseWidget._setupr c Cs|rt||f}||_t||||jdkr4g|_dd|D}|D]\}}||=qJ|j||jf|| ||D]\}}| ||q~dS)zdConstruct a widget with the parent widget MASTER, a name WIDGETNAME and appropriate options.NcSs"g|]\}}t|tr||fqSr )rr rIr r r r s z'BaseWidget.__init__..) r+ widgetNamer{r}rr%r2rrrr) rerr~r&rextraclassesr)r*r r r r s    zBaseWidget.__init__cCsTt|jD] }|q|jd|j|j|jjkrF|jj|j=t |dS)z)Destroy this and all descendants widgets.rN) rr#rRrr2rrrrrrSr r r r s   zBaseWidget.destroycCs|j|j|f|Srr)rerYrr r r _do szBaseWidget._doN)r )rArBrCrkr}rrrr 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)rArBrCrkr r r r r src@seZdZdZdifddZdS)Toplevelz"Toplevel widget, e.g. for dialogs.Nc Ks|rt||f}d}dD]L}||kr||}|ddkrJd|dd}nd|}|||f}||=qt||d|i||}|||||d|jdS) 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.r )rJclass_r(rWZcolormaprrr-NrTrO)r+r{rrrr4r-r) rerr&rrZwmkeyroptrrr r r r) s    zToplevel.__init__rArBrCrkrr r r r r& src@s.eZdZdZdifddZddZddZdS) rDzButton widget.NcKst||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 ZbuttonNrrrerr&rr r r rG szButton.__init__cCs|j|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. flashNrrr r r r\ s z Button.flashcCs|j|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. invokerrr r r rh sz Button.invoke)rArBrCrkrrrr r r r rDD s rDc@seZdZdZdifddZddZddZd d Zd d Zdwd dZ ddZ ddZ ddZ ddZ dxddZdyddZdzddZd{ddZdd 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#d|dCdDZ$dEdFZ%dGdHZ&dIdJZ'dKdLZ(dMdNZ)dOdPZ*dQdRZ+dSdTZ,dUdVZ-d}dWdXZ.e.Z/dYdZZ0e0Z1d[d\Z2d~d^d_Z3ifd`daZ4dbdcZ5e5Z6Z7dddeZ8dfdgZ9ddidjZ:dkdlZ;dmdnZdsdtZ?dudvZ@dS)Canvasz?Canvas widget to display graphical elements like lines or text.NcKst||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.ZcanvasNrrr r r rv s zCanvas.__init__cGs|j|jdf|dS)raddtagNrrr r r r sz Canvas.addtagcCs||d|dS)z*Add tag NEWTAG to all items above TAGORID.aboveNrrenewtagtagOrIdr r r addtag_above szCanvas.addtag_abovecCs||ddS)zAdd tag NEWTAG to all items.ruNr)rerr r r addtag_all szCanvas.addtag_allcCs||d|dS)z*Add tag NEWTAG to all items below TAGORID.belowNrrr r r addtag_below szCanvas.addtag_belowcCs||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.closestNr)rerrUrVhalostartr r r addtag_closest szCanvas.addtag_closestcCs||d||||dS)zLAdd tag NEWTAG to all items in the rectangle defined by X1,Y1,X2,Y2.enclosedNrrerx1y1x2y2r r r addtag_enclosed szCanvas.addtag_enclosedcCs||d||||dS)zWAdd tag NEWTAG to all items which overlap the rectangle defined by X1,Y1,X2,Y2. overlappingNrrr r r addtag_overlapping szCanvas.addtag_overlappingcCs||d|dS)z)Add tag NEWTAG to all items with TAGORID.withtagNrrr r r addtag_withtag szCanvas.addtag_withtagcGs ||j|jdf|pdS)z|Return a tuple of X1,Y1,X2,Y2 coordinates for a rectangle which encloses all items with tags specified as arguments.rNrArr r r r s z Canvas.bboxcCs(|j|jd||d|r$||dS)zbUnbind for all items with TAGORID for event SEQUENCE the function identified with FUNCID.rprZNrs)rerrlrnr r r tag_unbind szCanvas.tag_unbindcCs||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.rprq)rerrlrrr r r tag_bind s zCanvas.tag_bindcCs|j|j|jd||S)zrReturn the canvas x coordinate of pixel position SCREENX rounded to nearest multiple of GRIDSPACING units.canvasxr/)reZscreenx gridspacingr r r r s  zCanvas.canvasxcCs|j|j|jd||S)zrReturn the canvas y coordinate of pixel position SCREENY rounded to nearest multiple of GRIDSPACING units.canvasyr/)reZscreenyrr r r r s  zCanvas.canvasycs,fddjjjdf|DS)z8Return a list of coordinates for the item given in ARGS.csg|]}j|qSr )r2rrrr r r sz!Canvas.coords..coordsrhrr rr r s  z Canvas.coordsc Cs\t|}|d}t|ttfr,|dd}ni}|j|jj|jd|f||||S)rrNr@) rrrrr2rrrr)reitemTyperrr&r r r _create s zCanvas._createcOs|d||S)z6Create arc shaped region with coordinates x1,y1,x2,y2.Zarcrrr r r create_arc szCanvas.create_arccOs|d||S)z%Create bitmap with coordinates x1,y1.rrrr r r create_bitmap szCanvas.create_bitmapcOs|d||S)z)Create image item with coordinates x1,y1.rrrr r r create_image szCanvas.create_imagecOs|d||S)z-Create line with coordinates x1,y1,...,xn,yn.linerrr r r create_line szCanvas.create_linecOs|d||S)z)Create oval with coordinates x1,y1,x2,y2.Zovalrrr r r create_oval szCanvas.create_ovalcOs|d||S)z0Create polygon with coordinates x1,y1,...,xn,yn.Zpolygonrrr r r create_polygon szCanvas.create_polygoncOs|d||S)z.Create rectangle with coordinates x1,y1,x2,y2.Z rectanglerrr r r create_rectangle szCanvas.create_rectanglecOs|d||S)z#Create text with coordinates x1,y1.textrrr r r create_text szCanvas.create_textcOs|d||S)z+Create window with coordinates x1,y1,x2,y2.rrrr r r create_window szCanvas.create_windowcGs|j|jdf|dS)zDelete characters of text items identified by tag or id in ARGS (possibly several times) from FIRST to LAST character (including).dcharsNrrr r r r sz Canvas.dcharscGs|j|jdf|dS)zeZdZdZdifddZddZddZd d Zd d ZdS) RadiobuttonzGRadiobutton widget which shows only one of several buttons in on-state.NcKst||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.rNrrr r r rV s zRadiobutton.__init__cCs|j|jddSrrrr r r rb szRadiobutton.deselectcCs|j|jddSrrrr r r rg szRadiobutton.flashcCs|j|jdSrrrr r r rk szRadiobutton.invokecCs|j|jddSrrrr r r ro szRadiobutton.select) rArBrCrkrrrrrr r r r r+S s  r+c@s@eZdZdZdifddZddZddZd d d Zd d ZdS)Scalez1Scale widget which can display a numerical scale.NcKst||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.rNrrr r r rw s zScale.__init__c CsJ|j|jd}z|j|WStttfk rD|j|YSXdS)z*Get the current value as integer or float.rN)r2rrrrwr#rrrr r r r s z Scale.getcCs|j|jd|dS)zSet the value to VALUE.rNrrr r r r sz Scale.setcCs||j|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.rrArr r r r sz Scale.coordscCs|j|jd||S)zcReturn where the point X,Y lies. Valid return values are "slider", "though1" and "though2".identifyrrr r r r- szScale.identify)N) rArBrCrkrrrrr-r r r r r,t s   r,c@sPeZdZdZdifddZdddZddZd d Zd d Zd dZ ddZ dS) Scrollbarz?Scrollbar widget which displays a slider at a certain position.NcKst||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 scrollbarNrrr r r r s zScrollbar.__init__cCs|j|jd|pdS)aMarks the element indicated by index as active. The only index values understood by this method are "arrow1", "slider", or "arrow2". If any other value is specified then no element of the scrollbar will be active. If index is not specified, the method returns the name of the element that is currently active, or None if no element is active.rNrrr r r r szScrollbar.activatecCs|j|j|jd||S)znReturn the fractional change of the scrollbar setting if it would be moved by DELTAX or DELTAY pixels.rPr/)reZdeltaxZdeltayr r r rP szScrollbar.deltacCs|j|j|jd||S)zRReturn the fractional value which corresponds to a slider position of X,Y.rr/rr r r r szScrollbar.fractioncCs|j|jd||S)zYReturn the element under position X,Y as one of "arrow1","slider","arrow2" or "".r-rrr r r r- szScrollbar.identifycCs||j|jdS)zZReturn the current fractional values (upper and lower end) of the slider position.r)r}r2rrrr r r r sz Scrollbar.getcCs|j|jd||dS)ziSet the fractional values of the slider position (upper and lower ends as value between 0 and 1).rNrrr r r r sz Scrollbar.set)N) rArBrCrkrrrPrr-rrr r r r r. s r.c@seZdZdZdifddZddZddZd d Zdkd d Zdld dZ ddZ dmddZ ddZ dnddZ ddZddZddZddZdodd Zd!d"Zdpd#d$Zifd%d&Zd'd(Zd)d*Zd+d,Zdqd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zifd9d:Zd;d<Z d=d>Z!d?d@Z"dAdBZ#drdCdDZ$dEdFZ%dGdHZ&dsdIdJZ'dtdKdLZ(dMdNZ)dudOdPZ*e*Z+dQdRZ,dvdSdTZ-dwdUdVZ.dxdWdXZ/dydYdZZ0dzd[d\Z1d]d^Z2d{d_d`Z3dadbZ4d|dcddZ5e5Z6ifdedfZ7dgdhZ8didjZ9dS)}Textz4Text widget which can display text in various forms.NcKst||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, rNrrr r r r sz Text.__init__cCs||j|jd|pdS)zReturn a tuple of (x,y,width,height) which gives the bounding box of the visible part of the character at the given index.rNrArr r r r s z Text.bboxc Cs|j|j|jd|||S)zReturn whether between index INDEX1 and index INDEX2 the relation OP is satisfied. OP is one of <, <=, ==, >=, >, or !=.comparer*)rer opr!r r r r0 s z Text.comparecGsVdd|D}|||g7}|jj|jdf|p2d}|dk rNt|dkrN|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.cSsg|]}|dsd|qS)r-r) startswith)rJargr r r rs zText.count..r|N)r2rrr)rer r!rrr r r r| s  z Text.countcCs6|dkr |j|j|jdS|j|jd|dS)zjTurn on the internal consistency checks of the B-Tree inside the text widget according to BOOLEAN.Ndebugr*rr r r r5 sz Text.debugcCs|j|jd||dS)z?Delete the characters between INDEX1 and INDEX2 (not included).rNrrer r!r r r rsz Text.deletecCs||j|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. dlineinforArr r r r7szText.dlineinfoc Ksg}d}d}|s$g}|fdd}|}zzt|ts>||}}|d|g7}|D]} || rN|d| qN|||r|||jj|jdf||WS|r||XdS)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||||fdSr)rc)r6r rr%r r r append_triple/sz Text.dump..append_triplez-commandr-dump)rrrrrcr2rr) rer r!rrrZ func_namer%r8r6r r r r9s*      z Text.dumpcGs|jj|jdf|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 editrrr r r r:Bs z Text.editcCs |d|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. Zmodifiedr:)rer3r r r edit_modifiedQs zText.edit_modifiedcCs |dS)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. Zredor;rr r r edit_redo\szText.edit_redocCs |dS)z(Clears the undo and redo stacks resetr;rr r r edit_resetfszText.edit_resetcCs |dS)znInserts a separator (boundary) on the undo stack. Does nothing when the undo option is false rr;rr r r edit_separatorkszText.edit_separatorcCs |dS)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 Zundor;rr r r edit_undors zText.edit_undocCs|j|jd||S)z5Return the text from INDEX1 to INDEX2 (not included).rrr6r r r r}szText.getcCsJ|dddkrd|}|dddkr4|dd}|j|jdd||S)z9Return the value of OPTION of an embedded image at INDEX.Nrr-rrrrrr r r r image_cgets  zText.image_cgetcKs|dd|f||S)z%Configure an embedded image at INDEX.rrrrr r r image_configureszText.image_configurecKs"|jj|jdd|f|||S)z"Create an embedded image at INDEX.rr@rirr r r image_creates zText.image_createcCs|j|jddS)z3Return all names of embedded images in this widget.rrrrr r r rszText.image_namescCst|j|jd|S)z1Return the index in the form line.char for INDEX.r)rr2rrrr r r rsz Text.indexcGs|j|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.rNr)rercharsrr r r rsz Text.insertcCs|j|jdd||fS)zChange the gravity of a mark MARKNAME to DIRECTION (LEFT or RIGHT). Return the current value if None is given for DIRECTION.rZgravityr)remarkName directionr r r mark_gravityszText.mark_gravitycCs|j|j|jddS)zReturn all mark names.rrrhrr r r mark_namess  zText.mark_namescCs|j|jdd||dS)z0Set mark MARKNAME before the character at INDEX.rrNr)rerFrr r r mark_setsz Text.mark_setcGs|j|jddf|dS)zDelete all marks in MARKNAMES.rZunsetNr)reZ markNamesr r r mark_unsetszText.mark_unsetcCs|j|jdd|pdS)z-Return the name of the next mark after INDEX.rnextNrrr r r mark_nextszText.mark_nextcCs|j|jdd|pdS)z2Return the name of the previous mark before INDEX.rZpreviousNrrr r r mark_previousszText.mark_previouscKs&|jj|jdd|f|||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 overridden with the standard configuration options.peerr@Nri)reZ newPathNamer&rr r r peer_creates zText.peer_createcCs|j|j|jddS)zYReturns a list of peers of this widget (this does not include the widget itself).rOrrhrr r r peer_namesszText.peer_namescGs |jj|jd|||f|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.rNr)rer r!rErr r r rsz Text.replacecCs|j|jdd||dSrrrr r r rszText.scan_markcCs|j|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.rrNrrr r r rszText.scan_dragtoc Cs|jdg} |r| d|r&| d|r4| d|rB| d|rP| d| r^| d| rv| d| | |r|d d kr| d | || ||r| |t|jt| 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-r)rrcrr2rr) rerrZ stopindexZforwardsZ backwardsexactZregexpZnocaser|Zeliderr r r rs.            z Text.searchcCs|j|jd|dS)z3Scroll such that the character at INDEX is visible.rNrrr r r rszText.seecGs |j|jdd||f|dS)z|Add tag TAGNAME to all characters between INDEX1 and index2 in ARGS. Additional pairs of indices may follow in ARGS.tagrNr)retagNamer rr r r tag_addsz Text.tag_addcCs*|j|jdd||d|r&||dS)zgUnbind for all characters with TAGNAME for event SEQUENCE the function identified with FUNCID.rSrprZNrs)rerTrlrnr r r rszText.tag_unbindcCs||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.rSrprq)rerTrlrrr r r rs z Text.tag_bindcCsJ|dddkrd|}|dddkr4|dd}|j|jdd||S)z+Return the value of OPTION for tag TAGNAME.Nrr-rrrSrr)rerTrr r r tag_cget s  z Text.tag_cgetcKs|dd|f||S)zConfigure a tag TAGNAME.rSrr)rerTr&rr r r tag_configureszText.tag_configurecGs|j|jddf|dS)zDelete all tags in TAGNAMES.rSrNr)reZtagNamesr r r tag_deleteszText.tag_deletecCs|j|jdd||dS)z`Change the priority of tag TAGNAME such that it is lower than the priority of BELOWTHIS.rSrNr)rerTrr r r rszText.tag_lowercCs|j|j|jdd|S)zReturn a list of all tag names.rSrrhrr r r tag_names szText.tag_namesc Cs |j|j|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.rSZ nextrangerhrerTr r!r r r tag_nextrange%s zText.tag_nextrangec Cs |j|j|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.rSZ prevrangerhrZr r r tag_prevrange,s zText.tag_prevrangecCs|j|jdd||dS)zaChange the priority of tag TAGNAME such that it is higher than the priority of ABOVETHIS.rSrNr)rerTrr r r r3szText.tag_raisecCs|j|j|jdd|S)z7Return a list of ranges of text which have tag TAGNAME.rSZrangesrh)rerTr r r tag_ranges9s  zText.tag_rangescCs|j|jdd|||dS)zARemove tag TAGNAME from all characters between INDEX1 and INDEX2.rSrNrrZr r r tag_remove>szText.tag_removecCsJ|dddkrd|}|dddkr4|dd}|j|jdd||S)z:Return the value of OPTION of an embedded window at INDEX.Nrr-rrrrrr r r r window_cgetCs  zText.window_cgetcKs|dd|f||S)z&Configure an embedded window at INDEX.rrrrr r r window_configureKszText.window_configurecKs&|j|jdd|f|||dS)zCreate a window at INDEX.rr@Nrirr r r window_createQs   zText.window_createcCs|j|j|jddS)z4Return all names of embedded windows in this widget.rrrhrr r r window_namesWszText.window_namescGs|j|jddf|dS)zObsolete function, use see.rz -pickplaceNr)rerqr r r yview_pickplace\szText.yview_pickplace)N)N)NN)N)N)N)N)NNNNNNNN)N)N)N)N)N)N)N)N)N)N):rArBrCrkrrr0r|r5rr7r9r:r<r=r?r@rArrBrCrDrrrrHrIrJrKrMrNrPrQrrrrrrUrrrVrWZ tag_configrXrrYr[r\rr]r^r_r`Z window_configrarbrcr r r r r/ s~   (                   r/c@s"eZdZdZdddZddZdS)_setitz>Internal class. It wraps the command in the widget OptionMenu.NcCs||_||_||_dSr) _setit__value _setit__var_setit__callback)revarr rr r r rdsz_setit.__init__cGs*|j|j|jr&|j|jf|dSr)rfrrergrr r r risz_setit.__call__)Nrr r r r rdas rdc@s(eZdZdZddZddZddZdS) OptionMenuz?OptionMenu which allows the user to select a value from a menu.c Osd|dtddd}t||d|d|_t|ddd }|_|j|_|d }d |kr\|d =|rtt d t t ||j |t |||d |D]} |j | t || |d q||d<d S)zConstruct an optionmenu widget with the parent MASTER, with the resource textvariable set to VARIABLE, the initially selected value VALUE, the other menu values VALUES and an additional keyword argument command.r,rr')Z borderwidthZ textvariableZ indicatoronZreliefrZhighlightthicknessr(Z tk_optionMenur r)rYZtearoffrzunknown option -)rrN)ZRAISEDrrr~r _OptionMenu__menurZmenunamerrrLr0rrd) rerrr rRkwargsrr rr*r r r rrs.   zOptionMenu.__init__cCs|dkr|jSt||S)Nr )rjrrrr r r rszOptionMenu.__getitem__cCst|d|_dS)z,Destroy this widget and the associated menu.N)r'rrjrr r r rs zOptionMenu.destroyN)rArBrCrkrrrr r r r riosric@sheZdZdZdZdidfddZddZdd Zd d Zd d Z ddZ e Z ddZ ddZ ddZdS)ImagezBase class for images.rNc Ksd|_|std}t|d||_|s>tjd7_dtjf}|rT|rTt||f}n|r\|}d}|D]*\}}t|r| |}|d||f}qh|j dd||f|||_dS) Nz create imager2rz pyimage%rr r-rr@) rYrsr`r2rl_last_idr+r%rrr) reZimgtyperYr&rrrr)r*r r r rs$  zImage.__init__cCs|jSr)rYrr r r rFz Image.__str__cCs6|jr2z|jdd|jWntk r0YnXdS)Nrr)rYr2rrrr r r rs z Image.__del__cCs|j|jdd||dSNrr-r2rrYrr r r rszImage.__setitem__cCs|j|jdd|Srorprr r r rszImage.__getitem__cKsvd}t|D]J\}}|dk r|ddkr8|dd}t|rJ||}|d||f}q|j|jdf|dS)zConfigure the image.r Nrrr-r)r+r%rrr2rrY)rerrr)r*r r r rs  zImage.configurecCs|j|jdd|jS)zReturn the height of the image.rrXr2rrrYrr r r rXsz Image.heightcCs|jdd|jS)z7Return the type of the image, e.g. "photo" or "bitmap".rr rprr r r r sz Image.typecCs|j|jdd|jS)zReturn the width of the image.rrWrqrr r r rWsz Image.width)rArBrCrkrmrrFrrrrrrXr rWr r r r rls rlc@seZdZdZdidfddZddZddZd d Zd d ZdddZ dddZ ddZ dddZ dddZ ddZddZdS) PhotoImagez=Widget which can display images in PGM, PPM, GIF, PNG format.NcKstj|d|||f|dS)ztCreate an image with NAME. Valid resource names: data, format, file, gamma, height, palette, width.ZphotoNrlrrerYr&rrr r r rszPhotoImage.__init__cCs|j|jddS)zDisplay a transparent image.blankNrprr r r ruszPhotoImage.blankcCs|j|jdd|S)zReturn the value of OPTION.rr-rp)rerr r r rszPhotoImage.cgetcCs|j|jdd|S)Nrr-rprr r r rszPhotoImage.__getitem__cCs"t|jd}|j|d|j|S)z;Return a new PhotoImage with the same image as this widget.rcopyrrr2rrY)re destImager r r rvs zPhotoImage.copyrZcCs4t|jd}|dkr|}|j|d|jd|||S)zReturn a new PhotoImage with the same image as this widget but zoom it with a factor of x in the X direction and y in the Y direction. If y is not given, the default value is the same as x. rrZrvz-zoomrwrerUrVrxr r r zooms  zPhotoImage.zoomcCs4t|jd}|dkr|}|j|d|jd|||S)zReturn a new PhotoImage based on the same image as this widget but use only every Xth or Yth pixel. If y is not given, the default value is the same as x. rrZrvz -subsamplerwryr r r subsamples  zPhotoImage.subsamplecCs|j|jd||S)z8Return the color (red, green, blue) of the pixel at X,Y.rrprr r r r szPhotoImage.getcCsH|jd|f}|r8|ddkr(|dd}|dt|}|j|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}rYrr2r)rerrrr r r r| s    zPhotoImage.putcCs@|jd|f}|r|d|f}|r0|dt|}|j|dS)zRWrite image to file FILENAME in FORMAT starting from position FROM_COORDS.writez-format)z-fromNr~)refilenameformatZ from_coordsrr r r rs   zPhotoImage.writec Cs|j|j|jdd||S)z/Return True if the pixel at x,y is transparent. transparencyr)r2rrrYrr r r transparency_get"s zPhotoImage.transparency_getcCs|j|jdd|||dS)z)Set the transparency of the pixel at x,y.rrNrp)rerUrVrr r r transparency_set'szPhotoImage.transparency_set)rZ)rZ)N)NN)rArBrCrkrrurrrvrzr{rr|rrrr r r r rrs  rrc@s eZdZdZdidfddZdS) BitmapImagez.Widget which can display images in XBM format.NcKstj|d|||f|dS)zqCreate a bitmap with NAME. Valid resource names: background, data, file, foreground, maskdata, maskfile.rNrsrtr r r r/szBitmapImage.__init__rr r r r r,srcCstdj}||ddS)Nzuse image_names()rrrsr2r.rr2r r r r6s rcCstdj}||ddS)Nzuse image_types()rrrrr r r r;s rc@seZdZdZdifddZddZd+ddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd,d!d"Zd#d$Zd%d&Zd'd(Zd)d*ZdS)-Spinboxzspinbox widget.NcKst||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, ZspinboxNrrr r r rCszSpinbox.__init__cCs||j|jd|pdS)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. rNrArr r r r`s z Spinbox.bboxcCs|j|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. rrrr r r rns zSpinbox.deletecCs|j|jdS)zReturns the spinbox's stringrrrr r r rysz Spinbox.getcCs|j|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 rrrr r r r}szSpinbox.icursorcCs|j|jd||S)z{Returns the name of the widget at position x, y Return value is one of: none, buttondown, buttonup, entry r-rrr r r r-szSpinbox.identifycCs|j|jd|S)z;Returns the numerical index corresponding to index rrrr r r rsz Spinbox.indexcCs|j|jd||S)zDInsert string s at index Returns an empty string. rr)rerrfr r r rszSpinbox.insertcCs|j|jd|S)zCauses the specified element to be invoked The element could be buttondown or buttonup triggering the action associated with it. rrreelementr r r rszSpinbox.invokecGs ||j|jdf|pdS)rrr rArr r r rs z Spinbox.scancCs |d|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. rrr^r r r rszSpinbox.scan_markcCs |d|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. rrr^r r r rs zSpinbox.scan_dragtocGs ||j|jdf|pdS)rr r rArr r r r s zSpinbox.selectioncCs |d|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. rr rr r r rs zSpinbox.selection_adjustcCs |dS)zsClear the selection If the selection isn't in this widget then the command has no effect. rrrr r r rszSpinbox.selection_clearcCs|j|jdd|S)zSets or gets the currently selected element. If a spinbutton element is specified, it will be displayed depressed. r rrrr r r selection_elementszSpinbox.selection_elementcCs|d|dS)rrNrrr r r rszSpinbox.selection_fromcCs|j|j|jddS)zUReturn True if there are characters selected in the spinbox, False otherwise.r rr*rr r r rszSpinbox.selection_presentcCs|d||dS)rrNrrr r r rszSpinbox.selection_rangecCs|d|dS)rrNrrr r r rszSpinbox.selection_to)N)N)rArBrCrkrrrrrr-rrrrrrr rrrrrrrr r r r r@s*    rc@seZdZdZdifddZdS) LabelFramezlabelframe widget.NcKst||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 labelframeNrrr r r rszLabelFrame.__init__rr r r r rsrc@seZdZdZdifddZddZddZeZd d Zd d Z d dZ ddZ ddZ ddZ ddZddZddZddZd!ddZeZdd ZdS)" PanedWindowzpanedwindow widget.NcKst||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 panedwindowNrrr r r r szPanedWindow.__init__cKs"|j|jd|f||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. rNri)rer&rr r r rszPanedWindow.addcCs|j|jd|dS)zRemove the pane containing child from the panedwindow All geometry management options for child will be forgotten. rNr)rer&r r r r'szPanedWindow.removecCs|j|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-rrr r r r-0s zPanedWindow.identifycGs ||j|jdf|pdS)rproxyr rArr r r r<s zPanedWindow.proxycCs |dS)zBReturn the x and y pair of the most recent proxy location coordrrr r r proxy_coordAszPanedWindow.proxy_coordcCs |dS)z+Remove the proxy from the display. rrrr r r proxy_forgetFszPanedWindow.proxy_forgetcCs|d||S)z:Place the proxy at the given x and y coordinates. rrrr r r proxy_placeKszPanedWindow.proxy_placecGs ||j|jdf|pdS)rsashr rArr r r rPs zPanedWindow.sashcCs |d|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. rrrr r r sash_coordUs zPanedWindow.sash_coordcCs |d|S)zRecords x and y for the sash given by index; Used in conjunction with later dragto commands to move the sash. rrrr r r sash_markcszPanedWindow.sash_markcCs|d|||S)z?Place the sash given by index at the given coordinates rr)rerrUrVr r r sash_placejszPanedWindow.sash_placecCs|j|jdf|d|fS)zwQuery a management option for window. Option may be any value allowed by the paneconfigure subcommand panecgetr-r)rer&rr r r roszPanedWindow.panecgetcKsd|dkr|s||jd|St|tr@|s@||jd|d|S|j|jd|f|||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-)rrrrrr2rrrr r r rwsD  zPanedWindow.paneconfigurecCs|j|j|jdS)z+Returns an ordered list of the child panes.panesrhrr r r rszPanedWindow.panes)N)rArBrCrkrrrrr-rrrrrrrrrrZ paneconfigrr r r r r s$   LrcCst}dt}|d7}t||d}|t|d|fddd}|||_t|d|jd}|||| | dS) NzThis is Tcl/Tk version %su This should be a cedilla: çrz Click me!cSs|jjd|jddS)Nz[%s]rr)testr)rrr r r s z_test..)rrZQUIT) ro TclVersionrrrDrrrr!rr)rrrrrr{r r r _tests   r__main__)TN)N)r)r)NNror)VrkenumrrrZtkinter.constantsrerAfloatrPZ TkVersionrQrZREADABLEZWRITABLEZ EXCEPTIONcompilerASCIIrr rrr"r+r7rEnumr8rGrlrmrnrsrvrzrr{rrrrrrarrrrrrrrrorgrhrqrvr{rrrDrrrrrrr r'r)r+r,r.r/rdrirlrrrrrrrrrrAr r r r s        ,R  6  q2~ .37?/8$Vt!'2'BT 3C