>> from nltk.draw.util import TextWidget >>> cn = TextWidget(c, 'test', color='red') Attribute values can also be changed after a canvas widget has been constructed, using the ``__setitem__`` operator: >>> cn['font'] = 'times' The current value of an attribute value can be queried using the ``__getitem__`` operator: >>> cn['color'] red For a list of the attributes supported by a type of canvas widget, see its class documentation. Interaction. The attribute ``'draggable'`` controls whether the user can drag a canvas widget around the canvas. By default, canvas widgets are not draggable. ``CanvasWidget`` provides callback support for two types of user interaction: clicking and dragging. The method ``bind_click`` registers a callback function that is called whenever the canvas widget is clicked. The method ``bind_drag`` registers a callback function that is called after the canvas widget is dragged. If the user clicks or drags a canvas widget with no registered callback function, then the interaction event will propagate to its parent. For each canvas widget, only one callback function may be registered for an interaction event. Callback functions can be deregistered with the ``unbind_click`` and ``unbind_drag`` methods. Subclassing. ``CanvasWidget`` is an abstract class. Subclasses are required to implement the following methods: - ``__init__``: Builds a new canvas widget. It must perform the following three tasks (in order): - Create any new graphical elements. - Call ``_add_child_widget`` on each child widget. - Call the ``CanvasWidget`` constructor. - ``_tags``: Returns a list of the canvas tags for all graphical elements managed by this canvas widget, not including graphical elements managed by its child widgets. - ``_manage``: Arranges the child widgets of this canvas widget. This is typically only called when the canvas widget is created. - ``_update``: Update this canvas widget in response to a change in a single child. For a ``CanvasWidget`` with no child widgets, the default definitions for ``_manage`` and ``_update`` may be used. If a subclass defines any attributes, then it should implement ``__getitem__`` and ``__setitem__``. If either of these methods is called with an unknown attribute, then they should propagate the request to ``CanvasWidget``. Most subclasses implement a number of additional methods that modify the ``CanvasWidget`` in some way. These methods must call ``parent.update(self)`` after making any changes to the canvas widget's graphical elements. The canvas widget must also call ``parent.update(self)`` after changing any attribute value that affects the shape or position of the canvas widget's graphical elements. :type __canvas: Tkinter.Canvas :ivar __canvas: This ``CanvasWidget``'s canvas. :type __parent: CanvasWidget or None :ivar __parent: This ``CanvasWidget``'s hierarchical parent widget. :type __children: list(CanvasWidget) :ivar __children: This ``CanvasWidget``'s hierarchical child widgets. :type __updating: bool :ivar __updating: Is this canvas widget currently performing an update? If it is, then it will ignore any new update requests from child widgets. :type __draggable: bool :ivar __draggable: Is this canvas widget draggable? :type __press: event :ivar __press: The ButtonPress event that we're currently handling. :type __drag_x: int :ivar __drag_x: Where it's been moved to (to find dx) :type __drag_y: int :ivar __drag_y: Where it's been moved to (to find dy) :type __callbacks: dictionary :ivar __callbacks: Registered callbacks. Currently, four keys are used: ``1``, ``2``, ``3``, and ``'drag'``. The values are callback functions. Each callback function takes a single argument, which is the ``CanvasWidget`` that triggered the callback. cKsC|jtkrtdnt|ts<tdn||_||_t|dsig|_nd|_ d|_ d|_ d|_ |_i|_d|_x*t|jD]\}}|||ssN(t __class__Rt TypeErrort isinstanceRt_CanvasWidget__canvast_CanvasWidget__parentthasattrRt_CanvasWidget__hiddent_CanvasWidget__updatingtNonet_CanvasWidget__presst_CanvasWidget__drag_xt_CanvasWidget__drag_yt_CanvasWidget__callbackst_CanvasWidget__draggabletlisttitemst_managet_tagsttag_bindt_CanvasWidget__press_cb(tselftcanvastparenttattribstattrtvaluettag((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyt__init__s0            cCsJ|jr dSt|jdkr4tdn|jj|jS(s :return: A bounding box for this ``CanvasWidget``. The bounding box is a tuple of four coordinates, *(xmin, ymin, xmax, ymax)*, for a rectangle which encloses all of the canvas widget's graphical elements. Bounding box coordinates are specified with respect to the coordinate space of the ``Canvas``. :rtype: tuple(int, int, int, int) isNo tags(iiii(Rtlenttagst ValueErrorRtbbox(R%((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR0s cCsOt|jdkr'tdn|jj|j}|d|dS(s :return: The width of this canvas widget's bounding box, in its ``Canvas``'s coordinate space. :rtype: int isNo tagsi(R-R.R/RR0(R%R0((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pytwidthscCsOt|jdkr'tdn|jj|j}|d|dS(s :return: The height of this canvas widget's bounding box, in its ``Canvas``'s coordinate space. :rtype: int isNo tagsii(R-R.R/RR0(R%R0((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pytheightscCs|jS(s :return: The hierarchical parent of this canvas widget. ``self`` is considered a subpart of its parent for purposes of user interaction. :rtype: CanvasWidget or None (R(R%((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR'scCs|jS(s :return: A list of the hierarchical children of this canvas widget. These children are considered part of ``self`` for purposes of user interaction. :rtype: list of CanvasWidget (R(R%((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyt child_widgetsscCs|jS(si :return: The canvas that this canvas widget is bound to. :rtype: Tkinter.Canvas (R(R%((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR&scCsm||kodknr dSx*|jD]}|jj|||q-W|jri|jj|ndS(s Move this canvas widget by a given distance. In particular, shift the canvas widget right by ``dx`` pixels, and down by ``dy`` pixels. Both ``dx`` and ``dy`` may be negative, resulting in leftward or upward movement. :type dx: int :param dx: The number of pixels to move this canvas widget rightwards. :type dy: int :param dy: The number of pixels to move this canvas widget downwards. :rtype: None iN(R.RtmoveRtupdate(R%tdxtdyR+((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR4s  tNWcCs|j\}}}}|dkr?|j||||n|dkrr|j||d|d||n|dkr|j||||n|dkr|j||||d|dn|dkr|j||||n|dkr&|j||d|d||n|dkrM|j||||n|d kr|j||||d|dnd S( s% Move this canvas widget to the given location. In particular, shift the canvas widget such that the corner or side of the bounding box specified by ``anchor`` is at location (``x``, ``y``). :param x,y: The location that the canvas widget should be moved to. :param anchor: The corner or side of the canvas widget that should be moved to the specified location. ``'N'`` specifies the top center; ``'NE'`` specifies the top right corner; etc. R8tNitNEtEtSEtStSWtWN(R0R4(R%txtytanchortx1ty1tx2ty2((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pytmoveto+s"  '  '  '  cCs|jdk r |jjdSxM|jD]?}|jj|d|jj|d|jj|dq-W|jj|jd|_dS(s Remove this ``CanvasWidget`` from its ``Canvas``. After a ``CanvasWidget`` has been destroyed, it should not be accessed. Note that you only need to destroy a top-level ``CanvasWidget``; its child widgets will be destroyed automatically. If you destroy a non-top-level ``CanvasWidget``, then the entire top-level widget will be destroyed. :raise ValueError: if this ``CanvasWidget`` has a parent. :rtype: None Nsss(RRtdestroyR.Rt tag_unbindtdelete(R%R+((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRHCs cCsb|js|jrdS|jr#dSd|_|j||jrU|jj|nd|_dS(s Update the graphical display of this canvas widget, and all of its ancestors, in response to a change in one of this canvas widget's children. :param child: The child widget that changed. :type child: CanvasWidget Nii(RRt_updateRR5(R%tchild((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR5\s     cCs9|jr dSx|jD]}|jqW|jdS(s^ Arrange this canvas widget and all of its descendants. :rtype: None N(RRtmanageR!(R%RL((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRMts  cCs\|jdkrtdng}||j7}x!|jD]}||j7}q>W|S(s :return: a list of the canvas tags for all graphical elements managed by this canvas widget, including graphical elements managed by its child widgets. :rtype: list of int s+Attempt to access a destroyed canvas widgetN(RRR/R"RR.(R%R.RL((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR.~scCs,|dkr||_ntd|dS(s Set the value of the attribute ``attr`` to ``value``. See the class documentation for a list of attributes supported by this canvas widget. :rtype: None t draggablesUnknown attribute %rN(RR/(R%R)R*((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyt __setitem__s  cCs'|dkr|jStd|dS(s :return: the value of the attribute ``attr``. See the class documentation for a list of attributes supported by this canvas widget. :rtype: (any) RNsUnknown attribute %rN(RR/(R%R)((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyt __getitem__s cCsd|jjS(s] :return: a string representation of this canvas widget. :rtype: str s<%s>(Rt__name__(R%((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyt__repr__scCs:d|_x*|jD]}|jj|ddqWdS(sL Temporarily hide this canvas widget. :rtype: None itstatethiddenN(RR.Rt itemconfig(R%R+((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pythides cCs:d|_x*|jD]}|jj|ddqWdS(sD Show a hidden canvas widget. :rtype: None iRStnormalN(RR.RRU(R%R+((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pytshows cCs|jS(sU :return: True if this canvas widget is hidden. :rtype: bool (R(R%((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRTsicCs||j|ssNsiRNs( RtbindtunbindRtnumRt_CanvasWidget__start_dragR't_CanvasWidget__release_cb(R%teventtwidget((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyt __press_cbs    cCs2|jjd|j|j|_|j|_dS(s| Begin dragging this object: - register a motion callback - record the drag coordinates sN(RR`t_CanvasWidget__motion_cbR@RRAR(R%Re((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyt __start_drag$s cCs@|j|j|j|j|j|j|_|j|_dS(s Handle a motion event: - move this object to the new location - record the new drag coordinates N(R4R@RRAR(R%Re((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyt __motion_cb.s$ cCs|jjd|j|jjd|j|jjdkrt|j|jjt|j|jjdkr|jr|jdkr|j |jj|j |jj|j n|j |jn|jdkr|j nd|_dS(s Handle a release callback: - unregister motion & button release callbacks. - decide whether they clicked, dragged, or cancelled - call the appropriate handler. ssidiiN(RRaRbttimeRtabsR@RARR4RRt_CanvasWidget__clickt_CanvasWidget__dragR(R%Re((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyt __release_cb8s6 cCso|jrLd|jkrk|jd}y||WqId|GHqIXqkn|jdk rk|jjndS(s If this ``CanvasWidget`` has a drag callback, then call it; otherwise, find the closest ancestor with a drag callback, and call it. If no ancestors have a drag callback, do nothing. R\sError in drag callback for %rN(RRRRRn(R%tcb((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyt__dragPs  cCsO||jkr)|j|}||n"|jdk rK|jj|ndS(s If this ``CanvasWidget`` has a drag callback, then call it; otherwise, find the closest ancestor with a click callback, and call it. If no ancestors have a click callback, do nothing. N(RRRRm(R%RZRp((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyt__click`s   cCsYt|dsg|_n|jdk r<td|n||_|jj|dS(s Register a hierarchical child widget. The child will be considered part of this canvas widget for purposes of user interaction. ``_add_child_widget`` has two direct effects: - It sets ``child``'s parent to this canvas widget. - It adds ``child`` to the list of canvas widgets returned by the ``child_widgets`` member function. :param child: The new child widget. ``child`` must not already have a parent. :type child: CanvasWidget Rs%s already has a parentN(RRRRR/tappend(R%RL((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyt_add_child_widgetts   cCs|jj|d|_dS(s Remove a hierarchical child widget. This child will no longer be considered part of this canvas widget for purposes of user interaction. ``_add_child_widget`` has two direct effects: - It sets ``child``'s parent to None. - It removes ``child`` from the list of canvas widgets returned by the ``child_widgets`` member function. :param child: The child widget to remove. ``child`` must be a child of this canvas widget. :type child: CanvasWidget N(RtremoveRR(R%RL((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyt_remove_child_widgets cCs tdS(s :return: a list of canvas tags for all graphical elements managed by this canvas widget, not including graphical elements managed by its child widgets. :rtype: list of int N(tNotImplementedError(R%((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR"scCsdS(s Arrange the child widgets of this canvas widget. This method is called when the canvas widget is initially created. It is also called if the user calls the ``manage`` method on this canvas widget or any of its ancestors. :rtype: None N((R%((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR!s cCsdS(s Update this canvas widget in response to a change in one of its children. :param child: The child that changed. :type child: CanvasWidget :rtype: None N((R%RL((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRKs N(&RQt __module__t__doc__RR,R0R1R2R'R3R&R4RGRHR5RMR.RORPRRRVRXRTR[R]R^R_R$RcRhRdRnRmRtRvR"R!RK(((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR2sFq 9          #      t TextWidgetcBsMeZdZdZdZdZdZdZdZdZ RS(s A canvas widget that displays a single string of text. Attributes: - ``color``: the color of the text. - ``font``: the font used to display the text. - ``justify``: justification for multi-line texts. Valid values are ``left``, ``center``, and ``right``. - ``width``: the width of the text. If the text is wider than this width, it will be line-wrapped at whitespace. - ``draggable``: whether the text can be dragged by the user. cKs;||_|jddd||_tj|||dS(s  Create a new text widget. :type canvas: Tkinter.Canvas :param canvas: This canvas widget's canvas. :type text: str :param text: The string of text to display. :param attribs: The new canvas widget's attributes. ittextN(t_textt create_textt_tagRR,(R%R&R{R(((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR,s cCs[|dkrD|dkr!d}n|jj|ji||6ntj|||dS(NtcolortfonttjustifyR1tfill(scolorsfontsjustifyswidth(R&RUR~RRO(R%R)R*((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyROs   #cCsy|dkr+t|jj|j|S|dkre|dkrLd}n|jj|j|Stj||SdS(NR1RRRR(scolorsfontsjustify(tintR&titemcgetR~RRP(R%R)((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRPs   cCs |jgS(N(R~(R%((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR"scCs|jj|jdS(sV :return: The text displayed by this text widget. :rtype: str tTEXT(R&RR~(R%((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR{scCsH|jj|jd||jdk rD|jj|ndS(s Change the text that is displayed by this text widget. :type text: str :param text: The string of text to display. :rtype: None R{N(R&RUR~R'RR5(R%R{((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pytset_textscCs d|jS(Ns [Text: %r](R|(R%((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRRs( RQRxRyR,RORPR"R{RRR(((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRzs      t SymbolWidgetcBseZdZidd6dd6dd6dd6d d 6d d 6d d6dd6dd6dd6dd6dd6edd6dd6dd6dd 6d!d"6d#d$6Zd%Zd&Zd'Zd(Ze d)d*Z RS(+s A canvas widget that displays special symbols, such as the negation sign and the exists operator. Symbols are specified by name. Currently, the following symbol names are defined: ``neg``, ``disj``, ``conj``, ``lambda``, ``merge``, ``forall``, ``exists``, ``subseteq``, ``subset``, ``notsubset``, ``emptyset``, ``imp``, ``rightarrow``, ``equal``, ``notequal``, ``epsilon``. Attributes: - ``color``: the color of the text. - ``draggable``: whether the text can be dragged by the user. :cvar SYMBOLS: A dictionary mapping from symbols to the character in the ``symbol`` font used to render them. stnegstdisjstconjtltlambdastmerges"tforalls$texistsstsubseteqstsubsetst notsubsetstemptysetstimpit rightarrows=tequalstnotequalst intersectionstuniontetepsiloncKs1d|dt|jj|j|S|dkrc|jj|j|Stj||SdS(NRR1RR(soutlinesfillswidth(RtfloatR&RRRRP(R%R)((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRPs   cCsc|j\}}}}|j|dd}|jj|j||||||||dS(NR1i(R0RR&tcoordsR(R%RLRCRDRERFR((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRKs cCs |jgS(N(R(R%((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR"s(RQRxRyR,RORPRKR"(((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRs     t OvalWidgetcBsAeZdZdZdZdZdZdZdZRS(s A canvas widget that places a oval around a child widget. Attributes: - ``fill``: The color used to fill the interior of the oval. - ``outline``: The color used to draw the outline of the oval. - ``width``: The width of the outline of the oval. - ``margin``: The number of pixels space left between the child and the oval. - ``draggable``: whether the text can be dragged by the user. - ``double``: If true, then a double-oval is drawn. cKs||_d|_|jdddd|_|jdt|_|jdt|_|jr~|jdddd|_n d|_|j |jt j ||||dS(s: Create a new oval widget. :type canvas: Tkinter.Canvas :param canvas: This canvas widget's canvas. :param child: The child widget. ``child`` must not have a parent. :type child: CanvasWidget :param attribs: The new canvas widget's attributes. itcircletdoubleN( RRt create_ovalt_ovaltpoptFalset_circlet_doublet_oval2RRRR,(R%R&RLR(((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR,s    c Cs|j}|dkr$||_n|dkr|tkr|jdkr|j|j\}}}}|dd}|j||||||||d|j|jdd|j|jd|_|j |jn|t kr|jdk r|j |jd|_qn|dkr|j |ji||6|jdk rw|dkrw|j |ji||6n|jdk r|dkr|jj |ji||6qnt j|||dS(NRRR1iRR(Rsfillswidth(R&RtTrueRRR0RRRRRRJRURRO( R%R)R*tcRCRDRERFtw((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyROs*   % &cCs|dkr|jS|dkr,|jdk S|dkrWt|jj|j|S|dkr||jj|j|Stj||SdS(NRRR1RR(soutlinesfillswidth( RRRRR&RRRRP(R%R)((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRPs    g;f?cCstj}|j\}}}}|j}|jrt||t||}} || kr||d} | |d| |d}}q| |kr||d} | | d| | d}}qnt|d||d|d} | t|||} t|d||d|d}|t|||}|jj|j | |||| ||||j dk r|jj|j | |d||d| |d||dndS(Nii( RtRATIOR0RRRlRR&RRRR(R%RLtRRCRDRERFRR6R7RAR@RRRtbot((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRKs(   !   #$$ (cCs-|jdkr|jgS|j|jgSdS(N(RRR(R%((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR".s ( RQRxRyR,RORPRRKR"(((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRs     t ParenWidgetcBs;eZdZdZdZdZdZdZRS(s A canvas widget that places a pair of parenthases around a child widget. Attributes: - ``color``: The color used to draw the parenthases. - ``width``: The width of the parenthases. - ``draggable``: whether the text can be dragged by the user. c Ks}||_|jdddddddddd|_|jdddddddddd|_tj||||d S( sA Create a new parenthasis widget. :type canvas: Tkinter.Canvas :param canvas: This canvas widget's canvas. :param child: The child widget. ``child`` must not have a parent. :type child: CanvasWidget :param attribs: The new canvas widget's attributes. itstyletarctstartiZtextentiiN(Rt create_arct_oparent_cparenRR,(R%R&RLR(((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR,>s cCs|dkrG|jj|jd||jj|jd|nZ|dkr|jj|jd||jj|jd|ntj|||dS(NRRR1(R&RURRRRO(R%R)R*((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyROPs  cCs^|dkr%|jj|jdS|dkrJ|jj|jdStj||SdS(NRRR1(R&RRRRP(R%R)((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRPZs   cCs|j\}}}}t||dd}|jj|j|||||||jj|j||||||dS(Nii(R0tmaxR&RRR(R%RLRCRDRERFR1((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRKbs*cCs|j|jgS(N(RR(R%((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR"hs(RQRxRyR,RORPRKR"(((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR4s     t BracketWidgetcBs;eZdZdZdZdZdZdZRS(s A canvas widget that places a pair of brackets around a child widget. Attributes: - ``color``: The color used to draw the brackets. - ``width``: The width of the brackets. - ``draggable``: whether the text can be dragged by the user. c Ksq||_|jdddddddd|_|jdddddddd|_tj||||dS(s= Create a new bracket widget. :type canvas: Tkinter.Canvas :param canvas: This canvas widget's canvas. :param child: The child widget. ``child`` must not have a parent. :type child: CanvasWidget :param attribs: The new canvas widget's attributes. iN(Rt create_linet_obrackt_cbrackRR,(R%R&RLR(((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR,ts ''cCs|dkrG|jj|jd||jj|jd|nZ|dkr|jj|jd||jj|jd|ntj|||dS(NRRR1(R&RURRRRO(R%R)R*((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyROs  cCs^|dkr%|jj|jdS|dkrJ|jj|jdStj||SdS(NRRR1(R&RRRRP(R%R)((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRPs   c Cs|j\}}}}t||dd}|jj|j|||||||||| |jj|j|||||||||| dS(Nii(R0RR&RRR(R%RLRCRDRERFR1((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRKs ""cCs|j|jgS(N(RR(R%((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR"s(RQRxRyR,RORPRKR"(((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRjs     tSequenceWidgetcBszeZdZdZdZdZdZdZdZdZ dZ e j Z d Zd Zd ZRS( s A canvas widget that keeps a list of canvas widgets in a horizontal line. Attributes: - ``align``: The vertical alignment of the children. Possible values are ``'top'``, ``'center'``, and ``'bottom'``. By default, children are center-aligned. - ``space``: The amount of horizontal space to place between children. By default, one pixel of space is used. - ``ordered``: If true, then keep the children in their original order. cOs_d|_d|_t|_t||_x|D]}|j|q1Wtj|||dS(sj Create a new sequence widget. :type canvas: Tkinter.Canvas :param canvas: This canvas widget's canvas. :param children: The widgets that should be aligned horizontally. Each child must not have a parent. :type children: list(CanvasWidget) :param attribs: The new canvas widget's attributes. tcenteriN( t_alignt_spaceRt_orderedRt _childrenRtRR,(R%R&tchildrenR(RL((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR,s    cCs~|dkr7|dkr+td|n||_nC|dkrO||_n+|dkrg||_ntj|||dS( NtalignRRRsBad alignment: %rtspacetordered(stopsbottomscenter(R/RRRRRO(R%R)R*((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyROs     cCsM|dkr|jS|dkr&|jS|dkr9|jStj||SdS(NRRR(RRRRRP(R%R)((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRPs   cCsgS(N((R%((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR"scCsE|jdkr|S|jdkr&|S|jdkrA||dSdS(NRRRi(R(R%RR((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyt_yaligns cCs|j\}}}}|j||}xI|jD]>}|j\}} } } |jd||j| | q4W|jrt|jdkr|jj|} ||j} xt| dt|jD]d}|j|j\}} } } | |kr|j|j| |d| | ||j7} qqW||j} xt| dddD]d}|j|j\}} } } | | kr\|j|j| | d| | ||j8} q\q\WndS(Niii( R0RRR4RR-tindexRR(R%RLRRRRRARRCRDRERFRR@R((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRKs&$ #   cCst|jdkrdS|jd}|j\}}}}|j||}|jj|}||j}xt|dt|jD]e} |j| j\} } } } |j| j|| ||j| | || | |j7}qW||j}x}t|dddD]e} |j| j\} } } } |j| j|| ||j| | || | |j8}qWdS(Niii(R-RR0RRRRR4(R%RLRRRRRARR@RRCRDRERF((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR!s   #+ +cCsdt|jdd!dS(Ns [Sequence: iit](treprR(R%((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRRscCsJ|jj|}||j|<|j||j||j|dS(s Replace the child canvas widget ``oldchild`` with ``newchild``. ``newchild`` must not have a parent. ``oldchild``'s parent will be set to None. :type oldchild: CanvasWidget :param oldchild: The child canvas widget to remove. :type newchild: CanvasWidget :param newchild: The canvas widget that should replace ``oldchild``. N(RRRvRtR5(R%toldchildtnewchildR((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyt replace_child s    cCsY|jj|}|j|=|j|t|jdkrU|j|jdndS(s Remove the given child canvas widget. ``child``'s parent will be set ot None. :type child: CanvasWidget :param child: The child canvas widget to remove. iN(RRRvR-R5(R%RLR((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyt remove_childs   cCs$|jj|||j|dS(s Insert a child canvas widget before a given index. :type child: CanvasWidget :param child: The canvas widget that should be inserted. :type index: int :param index: The index where the child widget should be inserted. In particular, the index of ``child`` will be ``index``; and the index of any children whose indices were greater than equal to ``index`` before ``child`` was inserted will be incremented by one. N(RRRt(R%RRL((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyt insert_child-s (RQRxRyR,RORPR"RRKR!RRRR3RRRR(((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRs           t StackWidgetcBszeZdZdZdZdZdZdZdZdZ dZ e j Z d Zd Zd ZRS( s A canvas widget that keeps a list of canvas widgets in a vertical line. Attributes: - ``align``: The horizontal alignment of the children. Possible values are ``'left'``, ``'center'``, and ``'right'``. By default, children are center-aligned. - ``space``: The amount of vertical space to place between children. By default, one pixel of space is used. - ``ordered``: If true, then keep the children in their original order. cOs_d|_d|_t|_t||_x|D]}|j|q1Wtj|||dS(se Create a new stack widget. :type canvas: Tkinter.Canvas :param canvas: This canvas widget's canvas. :param children: The widgets that should be aligned vertically. Each child must not have a parent. :type children: list(CanvasWidget) :param attribs: The new canvas widget's attributes. RiN( RRRRRRRtRR,(R%R&RR(RL((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR,Ks    cCs~|dkr7|dkr+td|n||_nC|dkrO||_n+|dkrg||_ntj|||dS( NRRRRsBad alignment: %rRR(sleftsrightscenter(R/RRRRRO(R%R)R*((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRO]s     cCsM|dkr|jS|dkr&|jS|dkr9|jStj||SdS(NRRR(RRRRRP(R%R)((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRPfs   cCsgS(N((R%((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR"lscCsE|jdkr|S|jdkr&|S|jdkrA||dSdS(NRRRi(R(R%RR((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyt_xalignns cCs|j\}}}}|j||}xI|jD]>}|j\}} } } |j||j|| dq4W|jrt|jdkr|jj|} ||j} xt| dt|jD]d}|j|j\}} } } | | kr|j|jd| | | | | |j7} qqW||j} xt| dddD]d}|j|j\}} } } | | kr\|j|jd| | | | | |j8} q\q\WndS(Niii( R0RRR4RR-RRR(R%RLRRRRR@RRCRDRERFRRAR((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRKss&$ #   cCst|jdkrdS|jd}|j\}}}}|j||}|jj|}||j}xt|dt|jD]e} |j| j\} } } } |j| j||j| | || || | |j7}qW||j}x}t|dddD]e} |j| j\} } } } |j| j||j| | || || | |j8}qWdS(Niii(R-RR0RRRRR4(R%RLRRRRR@RRARRCRDRERF((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR!s   #+ +cCsdt|jdd!dS(Ns[Stack: iiR(RR(R%((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRRscCsJ|jj|}||j|<|j||j||j|dS(s Replace the child canvas widget ``oldchild`` with ``newchild``. ``newchild`` must not have a parent. ``oldchild``'s parent will be set to None. :type oldchild: CanvasWidget :param oldchild: The child canvas widget to remove. :type newchild: CanvasWidget :param newchild: The canvas widget that should replace ``oldchild``. N(RRRvRtR5(R%RRR((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRs    cCsY|jj|}|j|=|j|t|jdkrU|j|jdndS(s Remove the given child canvas widget. ``child``'s parent will be set ot None. :type child: CanvasWidget :param child: The child canvas widget to remove. iN(RRRvR-R5(R%RLR((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRs   cCs$|jj|||j|dS(s Insert a child canvas widget before a given index. :type child: CanvasWidget :param child: The canvas widget that should be inserted. :type index: int :param index: The index where the child widget should be inserted. In particular, the index of ``child`` will be ``index``; and the index of any children whose indices were greater than equal to ``index`` before ``child`` was inserted will be incremented by one. N(RRRt(R%RRL((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRs (RQRxRyR,RORPR"RRKR!RRRR3RRRR(((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR=s           t SpaceWidgetcBs;eZdZdZdZdZdZdZRS(sh A canvas widget that takes up space but does not display anything. A ``SpaceWidget`` can be used to add space between elements. Each space widget is characterized by a width and a height. If you wish to only create horizontal space, then use a height of zero; and if you wish to only create vertical space, use a width of zero. cKsj|dkr|d8}n|dkr2|d8}n|jdd||dd|_tj|||dS(si Create a new space widget. :type canvas: Tkinter.Canvas :param canvas: This canvas widget's canvas. :type width: int :param width: The width of the new space widget. :type height: int :param height: The height of the new space widget. :param attribs: The new canvas widget's attributes. iiRRN(RR~RR,(R%R&R1R2R(((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR,s  !cCsB|j\}}}}|jj|j|||||dS(s Change the width of this space widget. :param width: The new width. :type width: int :rtype: None N(R0R&RR~(R%R1RCRDRERF((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyt set_widthscCsB|j\}}}}|jj|j|||||dS(s Change the height of this space widget. :param height: The new height. :type height: int :rtype: None N(R0R&RR~(R%R2RCRDRERF((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyt set_heightscCs |jgS(N(R~(R%((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR" scCsdS(Ns[Space]((R%((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRRs(RQRxRyR,RRR"RR(((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRs   tScrollWatcherWidgetcBsDeZdZdZdZdZdZdZdZRS(s  A special canvas widget that adjusts its ``Canvas``'s scrollregion to always include the bounding boxes of all of its children. The scroll-watcher widget will only increase the size of the ``Canvas``'s scrollregion; it will never decrease it. cOs5x|D]}|j|qWtj|||dS(s Create a new scroll-watcher widget. :type canvas: Tkinter.Canvas :param canvas: This canvas widget's canvas. :type children: list(CanvasWidget) :param children: The canvas widgets watched by the scroll-watcher. The scroll-watcher will ensure that these canvas widgets are always contained in their canvas's scrollregion. :param attribs: The new canvas widget's attributes. N(RtRR,(R%R&RR(RL((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR,s cCs|j||j|dS(s0 Add a new canvas widget to the scroll-watcher. The scroll-watcher will ensure that the new canvas widget is always contained in its canvas's scrollregion. :param canvaswidget: The new canvas widget. :type canvaswidget: CanvasWidget :rtype: None N(RtR5(R%t canvaswidget((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyt add_child's cCs|j|dS(sA Remove a canvas widget from the scroll-watcher. The scroll-watcher will no longer ensure that the new canvas widget is always contained in its canvas's scrollregion. :param canvaswidget: The canvas widget to remove. :type canvaswidget: CanvasWidget :rtype: None N(Rv(R%R((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR4s cCsgS(N((R%((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR"@scCs|jdS(N(t_adjust_scrollregion(R%RL((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRKBscCs|j}|j}g|djD]}t|^q)}t|dkrWdS|d|dks|d|dks|d|dks|d|dkrdt|d|dt|d|dt|d|dt|d|df}||dcs jS(N(t print_to_file(R(R%(s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pytxss s torientt horizontaltverticalRtxscrollcommandRRRARRR@RtexpanditbothRs 0 0 %s %sR1R2RN(RR t_parentttitleR`RHRt_frameRt_canvasRtxviewRRRRt_scrollwatchert _init_menubar(R%R'tkwtframeR&t xscrollbart yscrollbarR((R%s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR,is0         c Cst|j}t|dd}|jddddd|jdd|jdd dd d|jdd |jdd ddd ||jjd |dS(NttearoffitlabelsPrint to Postscriptt underlineRt acceleratorsCtrl-ptExitisCtrl-xtFiletmenu(RRt add_commandRRHt add_cascadetconfig(R%tmenubartfilemenu((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRscCs|d krJddlm}ddg}|d|dd}|sJd Sn|j\}}}}|jjd |d |d |d |dd|dd|dd|ddddd d S(s Print the contents of this ``CanvasFrame`` to a postscript file. If no filename is given, then prompt the user for one. :param filename: The name of the file to print the tree to. :type filename: str :rtype: None i(tasksaveasfilenamesPostscript filess.pss All filest*t filetypestdefaultextensionNtfileR@RAR1iR2t pagewidtht pageheighttpagexitpagey(sPostscript filess.ps(s All filesR'(Rttkinter.filedialogR&RRt postscript(R%tfilenameR&tftypestx0ty0Rth((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRs      cCsG|jdj\}}}}t|t|t|t|fS(s :return: The current scroll region for the canvas managed by this ``CanvasFrame``. :rtype: 4-tuple of int R(RRR(R%RCRDRERF((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRscCs|jS(se :return: The canvas managed by this ``CanvasFrame``. :rtype: Tkinter.Canvas (R(R%((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR&scCsz|dks|dkr6|j|||\}}n|j\}}}}|j|||||jj|dS(sd Register a canvas widget with this ``CanvasFrame``. The ``CanvasFrame`` will ensure that this canvas widget is always within the ``Canvas``'s scrollregion. If no coordinates are given for the canvas widget, then the ``CanvasFrame`` will attempt to find a clear area of the canvas for it. :type canvaswidget: CanvasWidget :param canvaswidget: The new canvas widget. ``canvaswidget`` must have been created on this ``CanvasFrame``'s canvas. :type x: int :param x: The initial x coordinate for the upper left hand corner of ``canvaswidget``, in the canvas's coordinate space. :type y: int :param y: The initial y coordinate for the upper left hand corner of ``canvaswidget``, in the canvas's coordinate space. N(Rt _find_roomR0R4RR(R%RR@RARCRDRERF((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyt add_widgets cCsA|j\}}}}|j}|j} |||krDdS| ||krXdS|j\} } } } |j|| d|| d|dk r|}xpt||| t||| dD]C}|jj |d|d||d|| ds||fSqWn|dk r|}xpt|||t|||dD]C}|jj |d|d||d|| dsP||fSqPWnxt||| t||| dD]v}xmt|||t|||dD]C}|jj |d|d||d|| ds||fSqWqWdS( s9 Try to find a space for a given widget. ii2i i(ii(iiN(ii( RR1R2R0R4RRRRtfind_overlapping(R%Rft desired_xt desired_yRRRRRR5RCRDRERFR@RA((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR6s0    /3 /3//3cCs|j||jdS(s Remove a canvas widget from this ``CanvasFrame``. This deregisters the canvas widget, and destroys it. N(t remove_widgetRH(R%R((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pytdestroy_widgets cCs|jj|dS(N(RR(R%R((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR;scKs|jj||dS(sv Pack this ``CanvasFrame``. See the documentation for ``Tkinter.Pack`` for more information. N(RR(R%tcnfR((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRscGs-|jdkrdS|jjd|_dS(s Destroy this ``CanvasFrame``. If this ``CanvasFrame`` created a top-level window, then this will close that window. N(RRRH(R%R((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRHs cOs$tr dS|jj||dS(s Enter the Tkinter mainloop. This function must be called if this frame is created from a non-interactive program (e.g. from a secript); otherwise, the frame will close as soon as the script completes. N(RRR(R%targstkwargs((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR%s N(RQRxRyRR,RRRR&R7R6R<R;RRHR(((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR[s  -   !    tShowTextcBs8eZdZdddZdZdZdZRS(s A ``Tkinter`` window used to display a text. ``ShowText`` is typically used by graphical tools to display help text, or similar information. c Ks|dks|dkr6|j|||\}}n|dkrUt|_}nt||_}|j|t|ddd|j}|jddt |} | jdddd t | d d } | jdd dd t | ddd|d||} | j d|d| d<| jdddddd | j | d<| j| d<|jd|j|jd|j|jd|j|jd|j|jd|j| jdS(NR{tOkRRRR iRRR R RRAtwraptwordR1R2RtdisabledRSRRRR@Rss(Rtfind_dimentionsR t_topR RRRHRRRR RRRR`tfocus( R%trootRR{R1R2ttextbox_optionsRtbttbft scrollbarttextbox((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR,9s2       cCs|jd}|dkrCtd|D}t|d}nd}xX|D]P}x=t||kr|| jd}||}|d7}qYW|d7}qPWt|d}||fS(Ns css|]}t|VqdS(N(R-(t.0tline((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pys asiPit ii(RRRRR-trfind(R%R{R1R2tlinestmaxwidthROtbrk((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRE^s   cGs-|jdkrdS|jjd|_dS(N(RFRRH(R%R((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRHps cOs$tr dS|jj||dS(s Enter the Tkinter mainloop. This function must be called if this window is created from a non-interactive program (e.g. from a secript); otherwise, the window will close as soon as the script completes. N(RRFR(R%R>R?((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRus N(RQRxRyRR,RERHR(((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR@3s %  t EntryDialogcBsPeZdZdddddZdZdZdZdZdZ RS( s# A dialog box for entering Rc Cs{||_||_||_ttdt|dd}t||_|rf|jj|nt |j}|j dddddd d d d d |rt |d |}|j ddddddnt |d||_ |j j dddddd|j jd|t |jdddd} | j ddd ddd t |j} | j dddddd d d t| d dd|jdd} | j dddd t| d dd|jdddd} | j dddd t| d d d|jdd} | j dd|jjd!|j|jjd"|j|jjd#|j|j jdS($NiiiR iRRtpadxitpadytipadyi R{RRRBRR1R@it borderwidthtrelieftsunkentCancelRiRRAtdefaulttactiveRtApplyss s(Rt_original_textt _set_callbackRRR-R RFRRRRRt_entryRRt_cancelt_okt_applyR`RG( R%R't original_textt instructionst set_callbackRR1t entryframeRtdividertbuttonsRJ((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR,s<   #("!!cGsI|jjdd|jjd|j|jrE|j|jndS(NiR(RbRJRR`Ra(R%R((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyt_resets cGs&y|jWnnX|jdS(N(Rlt_destroy(R%R((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRcs cGs|j|jdS(N(ReRm(R%R((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRds cGs&|jr"|j|jjndS(N(RaRbtget(R%R((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRes cGs-|jdkrdS|jjd|_dS(N(RFRRH(R%R((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRms N( RQRxRyRR,RlRcRdReRm(((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRUs)    t ColorizedListcBseZdZgdZdZdZddZdZddZ dZ dZ d Z d Z dd Zid Zid ZdZdZdZdZdZRS(s An abstract base class for displaying a colorized list of items. Subclasses should define: - ``_init_colortags``, which sets up Text color tags that will be used by the list. - ``_item_repr``, which returns a list of (text,colortag) tuples that make up the colorized representation of the item. :note: Typically, you will want to register a callback for ``'select'`` that calls ``mark`` on the given item. cKst||_i|_i|_|j|j|jjd|j|jjd|jd|_ |j |dS(s Construct a new list. :param parent: The Tk widget that contains the colorized list :param items: The initial contents of the colorized list. :param options: s s N( Rt _callbackst_markst_init_itemframetcopyt _textwidgetR`t _keypresst _buttonpressRt_itemsR(R%R'R toptions((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyR,s    cCs tdS(s Set up any colortags that will be used by this colorized list. E.g.: >>> textwidget.tag_config('terminal', foreground='black') N(Rw(R%t textwidgetRx((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyt_init_colortagsscCs tdS(s Return a list of (text, colortag) tuples that make up the colorized representation of the item. Colorized representations may not span multiple lines. I.e., the text strings returned may not contain newline characters. N(Rw(R%titem((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyt _item_reprscCs#|dkr|jS|j|SdS(sF :return: A list of the items contained by this list. N(RRw(R%R((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRn s cCst|}|j|krdSt||_d|jd<|jjddxo|D]g}xK|j|D]:\}}d|kstd|jjd||qkW|jjddqUW|jjdd|jjd dd |jd<|jj dS( sB Modify the list of items contained by this list. NRWRSs1.0Rs s!item repr may not contain newlines end-1charRRD( RRwRtRJR|tAssertionErrorRtmark_setRqtclear(R%R R{R{tcolortag((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pyRs    cCs|dkr2|jj|jjdddnO|jj|}|j|=d|dd|d}}|jjd||dS(s Remove highlighting from the given item; or from every item, if no item is given. :raise ValueError: If ``item`` is not contained in the list. :raise KeyError: If ``item`` is not marked. t highlights1.0s end+1chars%d.0iiN(RRqRRtt tag_removeRwR(R%R{RRR((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pytunmark*s   cCsVd|j|<|jj|}d|dd|d}}|jjd||dS(sp Highlight the given item. :raise ValueError: If ``item`` is not contained in the list. is%d.0iRN(RqRwRRtttag_add(R%R{RRR((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pytmark:s cCs|j|j|dS(s Remove any current highlighting, and mark the given item. :raise ValueError: If ``item`` is not contained in the list. N(RR(R%R{((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pytmarkonlyDs cCs.|jj|}|jjd|ddS(s Adjust the view such that the given item is visible. If the item is already visible, then do nothing. s%d.0iN(RwRRttsee(R%R{R((s`/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/util.pytviewLscCsv|dkrdddg}n*|dkr?dddd g}n |g}x'|D]}d |jj|i|eZdZdZdZdZdZdZRS(cKs|jd|_d|kr(|d=nt|_}t|dkr^|j|dnidd6|d6dd6td6d d 6dd 6}|j|tj ||d |d |_ t |dddd|_ |j j |_g|_x|D]}|j|qW|j |d#s6 ^$C^75i666KPJ7 )