grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026a BjŒjÅðã@spddlmZmZddlmZddlmZmZddlm Z m Z m Z m Z m Z mZddlmZmZmZddlmZddlmZddlmZmZmZmZdd lmZmZmZmZm Z m!Z!m"Z"dd l#m$Z$m%Z%m&Z&d Z'd Z(d Z)dZ*dZ+dZ,dZ-dZ.dZ/dZ0dZ1dZ2dZ3dZ4dZ5dZ6e6dfZ7dZ8Gdd„de ej9ƒZ:Gdd „d e;ƒZd%d&„Z?d'd(„Z@d)d*„ZAd+d,„ZBGd-d.„d.ee:eCƒƒZDGd/d0„d0eDƒZEGd1d2„d2eDƒZFd3d4„ZGGd5d6„d6eDƒZHGd7d8„d8eDƒZIGd9d:„d:eFƒZJGd;d<„d„d>eDƒZLGd?d@„d@eKƒZMGdAdB„dBeLƒZNGdCdD„dDeNƒZOdEdF„ZPGdGdH„dHe;ƒZQGdIdJ„dJePdKƒeDƒZRdLdM„ZSeTdNk�rleSƒdOS)Pé)ÚdivisionÚprint_function)Ú attrgetter)Ú text_typeÚwith_metaclass)Ú MetaSuperÚdecompose_tagmarkupÚ calc_widthÚ is_wide_charÚmove_prev_charÚmove_next_char)Úcalc_posÚ calc_coordsÚ shift_line)Úsignals)Ú text_layout)Ú CanvasCacheÚCompositeCanvasÚ SolidCanvasÚapply_text_layout)Ú command_mapÚ CURSOR_LEFTÚ CURSOR_RIGHTÚ CURSOR_UPÚ CURSOR_DOWNÚCURSOR_MAX_LEFTÚCURSOR_MAX_RIGHT)Ú split_reprÚremove_defaultsÚ python3_reprZflowZboxÚfixedÚleftÚrightÚcenterÚtopZmiddleÚbottomÚspaceÚanyZclipZellipsisÚpackZgivenÚrelativeédZweightcs eZdZdZ‡fdd„Z‡ZS)Ú WidgetMetaaÔ Bases: :class:`MetaSuper`, :class:`MetaSignals` Automatic caching of render and rows methods. Class variable *no_cache* is a list of names of methods to not cache automatically. Valid method names for *no_cache* are ``'render'`` and ``'rows'``. Class variable *ignore_focus* if defined and set to ``True`` indicates that the canvas this widget renders is not affected by the focus parameter, so it may be ignored when caching. cs~| dg¡}tt|ƒ |||¡d|vrHd|vr:t|ƒ}nt|ƒ}||_d|vrbd|vrbt|ƒ|_d|vrn|` d|vrz|` dS)NÚno_cacheÚrenderÚrowsÚ ignore_focus) ÚgetÚsuperr+Ú__init__Úcache_widget_renderÚnocache_widget_renderr-Úcache_widget_rowsr.r,r/)ÚclsÚnameÚbasesÚdr,Z render_fn©Ú __class__©ú2/usr/lib64/python3.9/site-packages/urwid/widget.pyr2Us   zWidgetMeta.__init__)Ú__name__Ú __module__Ú __qualname__Ú__doc__r2Ú __classcell__r<r<r:r=r+Gs r+c@s eZdZdS)Ú WidgetErrorN©r>r?r@r<r<r<r=rChsrCcCs`|r$|dd…dkr$|d| ¡ks@t|ƒdkr\|d| ¡kr\td|| ¡| ¡|fƒ‚dS)zA Raise a WidgetError if a canv does not match size size. éN)rrz8Widget %r rendered (%d x %d) canvas when passed size %r!)ÚcolsÚlenr.rC)ÚwidgetÚsizeÚcanvr<r<r=Ú validate_sizeks$ ÿÿÿÿrKcCsBz*|j|_|j |j¡|j|_|j|_Wnty<Yn0dS)zN Copy as much of the function detail from fn to new_fn as we can. N)r>Ú__dict__ÚupdaterAr?Ú TypeError)Znew_fnÚfnr<r<r=Úupdate_wrapperus  rPcs<ttˆddƒƒ‰ˆj‰d‡‡‡fdd„ }ˆ|_t|ˆƒ|S)zt Return a function that wraps the cls.render() method and fetches and stores canvases with CanvasCache. r/Fcsh|oˆ }t |ˆ||¡}|r"|Sˆ|||d�}t|||ƒ|jrJt|ƒ}| |||¡t ˆ|¡|S©N)Úfocus)rÚfetchrKÚ widget_inforÚfinalizeÚstore©ÚselfrIrRrJ©r6rOr/r<r=Ú cached_renderŠs   z*cache_widget_render..cached_render)F)ÚboolÚgetattrr-Ú original_fnrP)r6rZr<rYr=r3ƒs   r3cs8|j‰tˆdƒrˆj‰d‡fdd„ }ˆ|_t|ˆƒ|S)zl Return a function that wraps the cls.render() method and finalizes the canvas that it returns. r]Fcs:ˆ|||d�}|jrt|ƒ}t|||ƒ| |||¡|SrQ)rTrrKrUrW©rOr<r=Úfinalize_render£s  z.nocache_widget_render..finalize_render)F)r-Úhasattrr]rP)r6r_r<r^r=r4›s  r4cs,ˆjj‰d‡‡fdd„ }ˆ|_t|ˆƒ|S)z� Return a function that wraps the cls.render() method and finalizes the canvas that it returns, but does not cache the canvas. Fcs.ˆˆ||d�}|jrt|ƒ}| ˆ||¡|SrQ)rTrrU)rIrRrJ©rOrXr<r=r_µs z7nocache_widget_render_instance..finalize_render)F)r-r]rP)rXr_r<rar=Únocache_widget_render_instance®s  rbcs6ttˆddƒƒ‰ˆj‰d‡‡‡fdd„ }t|ˆƒ|S)zt Return a function that wraps the cls.rows() method and returns rows from the CanvasCache if available. r/Fcs2|oˆ }t |ˆ||¡}|r&| ¡Sˆ|||ƒS©N)rrSr.rWrYr<r=Ú cached_rowsÆs  z&cache_widget_rows..cached_rows)F)r[r\r.rP)r6rdr<rYr=r5¿s  r5c@s eZdZdZdZeeeegƒZ e Z dd„Z dd„Z dd„Zd d „Zdd d „Zed d„dd�Zedd„dd�Zddd„Zeeedd�Zdd„Zdd„Zdd„ZdS)ÚWidgetaL# Widget base class .. attribute:: _selectable :annotation: = False The default :meth:`.selectable` method returns this value. .. attribute:: _sizing :annotation: = frozenset(['flow', 'box', 'fixed']) The default :meth:`.sizing` method returns this value. .. attribute:: _command_map :annotation: = urwid.command_map A shared :class:`CommandMap` instance. May be redefined in subclasses or widget instances. .. method:: render(size, focus=False) .. note:: This method is not implemented in :class:`.Widget` but must be implemented by any concrete subclass :param size: One of the following, *maxcol* and *maxrow* are integers > 0: (*maxcol*, *maxrow*) for box sizing -- the parent chooses the exact size of this widget (*maxcol*,) for flow sizing -- the parent chooses only the number of columns for this widget () for fixed sizing -- this widget is a fixed size which can't be adjusted by the parent :type size: widget size :param focus: set to ``True`` if this widget or one of its children is in focus :type focus: bool :returns: A :class:`Canvas` subclass instance containing the rendered content of this widget :class:`Text` widgets return a :class:`TextCanvas` (arbitrary text and display attributes), :class:`SolidFill` widgets return a :class:`SolidCanvas` (a single character repeated across the whole surface) and container widgets return a :class:`CompositeCanvas` (one or more other canvases arranged arbitrarily). If *focus* is ``False``, the returned canvas may not have a cursor position set. There is some metaclass magic defined in the :class:`Widget` metaclass :class:`WidgetMeta` that causes the result of this method to be cached by :class:`CanvasCache`. Later calls will automatically look up the value in the cache first. As a small optimization the class variable :attr:`ignore_focus` may be defined and set to ``True`` if this widget renders the same canvas regardless of the value of the *focus* parameter. Any time the content of a widget changes it should call :meth:`_invalidate` to remove any cached canvases, or the widget may render the cached canvas instead of creating a new one. .. method:: rows(size, focus=False) .. note:: This method is not implemented in :class:`.Widget` but must be implemented by any flow widget. See :meth:`.sizing`. See :meth:`Widget.render` for parameter details. :returns: The number of rows required for this widget given a number of columns in *size* This is the method flow widgets use to communicate their size to other widgets without having to render a canvas. This should be a quick calculation as this function may be called a number of times in normal operation. If your implementation may take a long time you should add your own caching here. There is some metaclass magic defined in the :class:`Widget` metaclass :class:`WidgetMeta` that causes the result of this function to be retrieved from any canvas cached by :class:`CanvasCache`, so if your widget has been rendered you may not receive calls to this function. The class variable :attr:`ignore_focus` may be defined and set to ``True`` if this widget renders the same size regardless of the value of the *focus* parameter. .. method:: keypress(size, key) .. note:: This method is not implemented in :class:`.Widget` but must be implemented by any selectable widget. See :meth:`.selectable`. :param size: See :meth:`Widget.render` for details :type size: widget size :param key: a single keystroke value; see :ref:`keyboard-input` :type key: bytes or unicode :returns: ``None`` if *key* was handled by this widget or *key* (the same value passed) if *key* was not handled by this widget Container widgets will typically call the :meth:`keypress` method on whichever of their children is set as the focus. The standard widgets use :attr:`_command_map` to determine what action should be performed for a given *key*. You may modify these values to your liking globally, at some level in the widget hierarchy or on individual widgets. See :class:`CommandMap` for the defaults. In your own widgets you may use whatever logic you like: filtering or translating keys, selectively passing along events etc. .. method:: mouse_event(size, event, button, col, row, focus) .. note:: This method is not implemented in :class:`.Widget` but may be implemented by a subclass. Not implementing this method is equivalent to having a method that always returns ``False``. :param size: See :meth:`Widget.render` for details. :type size: widget size :param event: Values such as ``'mouse press'``, ``'ctrl mouse press'``, ``'mouse release'``, ``'meta mouse release'``, ``'mouse drag'``; see :ref:`mouse-input` :type event: mouse event :param button: 1 through 5 for press events, often 0 for release events (which button was released is often not known) :type button: int :param col: Column of the event, 0 is the left edge of this widget :type col: int :param row: Row of the event, 0 it the top row of this widget :type row: int :param focus: Set to ``True`` if this widget or one of its children is in focus :type focus: bool :returns: ``True`` if the event was handled by this widget, ``False`` otherwise Container widgets will typically call the :meth:`mouse_event` method on whichever of their children is at the position (*col*, *row*). .. method:: get_cursor_coords(size) .. note:: This method is not implemented in :class:`.Widget` but must be implemented by any widget that may return cursor coordinates as part of the canvas that :meth:`render` returns. :param size: See :meth:`Widget.render` for details. :type size: widget size :returns: (*col*, *row*) if this widget has a cursor, ``None`` otherwise Return the cursor coordinates (*col*, *row*) of a cursor that will appear as part of the canvas rendered by this widget when in focus, or ``None`` if no cursor is displayed. The :class:`ListBox` widget uses this method to make sure a cursor in the focus widget is not scrolled out of view. It is a separate method to avoid having to render the whole widget while calculating layout. Container widgets will typically call the :meth:`.get_cursor_coords` method on their focus widget. .. method:: get_pref_col(size) .. note:: This method is not implemented in :class:`.Widget` but may be implemented by a subclass. :param size: See :meth:`Widget.render` for details. :type size: widget size :returns: a column number or ``'left'`` for the leftmost available column or ``'right'`` for the rightmost available column Return the preferred column for the cursor to be displayed in this widget. This value might not be the same as the column returned from :meth:`get_cursor_coords`. The :class:`ListBox` and :class:`Pile` widgets call this method on a widget losing focus and use the value returned to call :meth:`.move_cursor_to_coords` on the widget becoming the focus. This allows the focus to move up and down through widgets while keeping the cursor in approximately the same column on screen. .. method:: move_cursor_to_coords(size, col, row) .. note:: This method is not implemented in :class:`.Widget` but may be implemented by a subclass. Not implementing this method is equivalent to having a method that always returns ``False``. :param size: See :meth:`Widget.render` for details. :type size: widget size :param col: new column for the cursor, 0 is the left edge of this widget :type col: int :param row: new row for the cursor, 0 it the top row of this widget :type row: int :returns: ``True`` if the position was set successfully anywhere on *row*, ``False`` otherwise FcCst |¡dS)zt Mark cached canvases rendered by this widget as dirty so that they will not be used again. N)rZ invalidate©rXr<r<r=Ú _invalidateÀszWidget._invalidatecGstj|||g|¢RŽdS)z[ Convenience function to emit signals with self as first argument. N)rZ emit_signal)rXr7Úargsr<r<r=Ú_emitÇsz Widget._emitcCs|jS)ao :returns: ``True`` if this is a widget that is designed to take the focus, i.e. it contains something the user might want to interact with, ``False`` otherwise, This default implementation returns :attr:`._selectable`. Subclasses may leave these is if the are not selectable, or if they are always selectable they may set the :attr:`_selectable` class variable to ``True``. If this method returns ``True`` then the :meth:`.keypress` method must be implemented. Returning ``False`` does not guarantee that this widget will never be in focus, only that this widget will usually be skipped over when changing focus. It is still possible for non selectable widgets to have the focus (typically when there are no other selectable widgets visible). )Ú _selectablerfr<r<r=Ú selectableÎszWidget.selectablecCs|jS)a3 :returns: A frozenset including one or more of ``'box'``, ``'flow'`` and ``'fixed'``. Default implementation returns the value of :attr:`._sizing`, which for this class includes all three. The sizing modes returned indicate the modes that may be supported by this widget, but is not sufficient to know that using that sizing mode will work. Subclasses should make an effort to remove sizing modes they know will not work given the state of the widget, but many do not yet do this. If a sizing mode is missing from the set then the widget should fail when used in that mode. If ``'flow'`` is among the values returned then the other methods in this widget must be able to accept a single-element tuple (*maxcol*,) to their ``size`` parameter, and the :meth:`rows` method must be defined. If ``'box'`` is among the values returned then the other methods must be able to accept a two-element tuple (*maxcol*, *maxrow*) to their size parameter. If ``'fixed'`` is among the values returned then the other methods must be able to accept an empty tuple () to their size parameter, and the :meth:`pack` method must be defined. )Ú_sizingrfr<r<r=Úsizingãsz Widget.sizingcCsh|s*t| ¡vrtdƒ‚tdt|ƒƒ‚n:t|ƒdkrdt| ¡vrT|| ||¡fStdt|ƒƒ‚|S)ad See :meth:`Widget.render` for parameter details. :returns: A "packed" size (*maxcol*, *maxrow*) for this widget Calculate and return a minimum size where all content could still be displayed. Fixed widgets must implement this method and return their size when ``()`` is passed as the *size* parameter. This default implementation returns the *size* passed, or the *maxcol* passed and the value of :meth:`rows` as the *maxrow* when (*maxcol*,) is passed as the *size* parameter. .. note:: This is a new method that hasn't been fully implemented across the standard widget types. In particular it has not yet been implemented for container widgets. :class:`Text` widgets have implemented this method. You can use :meth:`Text.pack` to calculate the minimum columns and rows required to display a text widget without wrapping, or call it iteratively to calculate the minimum number of columns required to display the text wrapped into a target number of rows. z)Fixed widgets must override Widget.pack()z3Cannot pack () size, this is not a fixed widget: %srEz9Cannot pack (maxcol,) size, this is not a flow widget: %s)ÚFIXEDrmÚNotImplementedErrorrCÚreprrGÚFLOWr.©rXrIrRr<r<r=r(s ÿ  ÿz Widget.packcCs|Srcr<rfr<r<r=Ú+ózWidget.z¦ Read-only property that steps through decoration widgets and returns the one at the base. This default implementation returns self. ©ÚdoccCsdSrcr<rfr<r<r=rs1rtzÒ Read-only property returning the child widget in focus for container widgets. This default implementation always returns ``None``, indicating that this widget has no children. NcCstd|ƒ‚dS)Nz/No focus_position, %r is not a container widget)Ú IndexError©rXÚvalr<r<r=Ú_not_a_container7sÿzWidget._not_a_containera Property for reading and setting the focus position for container widgets. This default implementation raises :exc:`IndexError`, making normal widgets fail the same way accessing :attr:`.focus_position` on an empty container widget would. cCst|ƒS)z‰ A friendly __repr__ for widgets, designed to be extended by subclasses with _repr_words and _repr_attr methods. )rrfr<r<r=Ú__repr__AszWidget.__repr__cCsbg}| ¡rdg|}| ¡rX| ¡ttttgƒkrXt| ¡ƒ}| ¡| d  |¡¡|dgS)Nrkú/rH) rkrmÚ frozensetrqÚBOXrnÚlistÚsortÚappendÚjoin)rXÚwordsZ sizing_modesr<r<r=Ú _repr_wordsHs  zWidget._repr_wordscCsiSrcr<rfr<r<r=Ú _repr_attrsRszWidget._repr_attrs)F)N)r>r?r@rArjr}rqr~rnrlrÚ _command_maprgrirkrmr(ÚpropertyZ base_widgetrRrzZfocus_positionr{r„r…r<r<r<r=reÑs"k (  rec@s.eZdZdZeegƒZddd„Zd dd„ZdS) Ú FlowWidgetzë Deprecated. Inherit from Widget and add: _sizing = frozenset(['flow']) at the top of your class definition instead. Base class of widgets that determine their rows from the number of columns available. FcCs tƒ‚dS)z@ All flow widgets must implement this function. N©rorrr<r<r=r.cszFlowWidget.rowscCs tƒ‚dS©z; All widgets must implement this function. Nr‰rrr<r<r=r-iszFlowWidget.renderN)F)F) r>r?r@rAr}rqrlr.r-r<r<r<r=rˆVs  rˆc@s(eZdZdZdZeegƒZddd„ZdS)Ú BoxWidgeta Deprecated. Inherit from Widget and add: _sizing = frozenset(['box']) _selectable = True at the top of your class definition instead. Base class of width and height constrained widgets such as the top level widget attached to the display object TFcCs tƒ‚dSrŠr‰rrr<r<r=r-szBoxWidget.renderN)F) r>r?r@rArjr}r~rlr-r<r<r<r=r‹ps  r‹cCs|dkrtd|fƒ‚dS)z[ raise ValueError if size != (). Used by FixedWidgets to test size parameter. r<z-FixedWidget takes only () for size.passed: %rN)Ú ValueError)rIr<r<r=Ú fixed_size†sÿr�c@s.eZdZdZeegƒZddd„Zd dd„ZdS) Ú FixedWidgetzã Deprecated. Inherit from Widget and add: _sizing = frozenset(['fixed']) at the top of your class definition instead. Base class of widgets that know their width and height and cannot be resized FcCs tƒ‚dSrŠr‰rrr<r<r=r-�szFixedWidget.renderNcCs tƒ‚dS)zA All fixed widgets must implement this function. Nr‰rrr<r<r=r(£szFixedWidget.pack)F)NF) r>r?r@rAr}rnrlr-r(r<r<r<r=rŽ�s  rŽc@sLeZdZdZeegƒZdZddd„Zdd„Z d d „Z dd d „Z ddd„Z dS)ÚDividerz# Horizontal divider widget Tú rcCs |j ¡||_||_||_dS)aà :param div_char: character to repeat across line :type div_char: bytes or unicode :param top: number of blank lines above :type top: int :param bottom: number of blank lines below :type bottom: int >>> Divider() >>> Divider(u'-') >>> Divider(u'x', 1, 2) N)Ú_Divider__superr2Údiv_charr$r%)rXr’r$r%r<r<r=r2²s zDivider.__init__cCs |j ¡t|jƒg|jdkS)Nr�)r‘r„rr’rfr<r<r=r„És ÿÿzDivider._repr_wordscCs2t|j ¡ƒ}|jr|j|d<|jr.|j|d<|S)Nr$r%)Údictr‘r…r$r%©rXÚattrsr<r<r=r…ÍszDivider._repr_attrsFcCs|\}|jd|jS)z¦ Return the number of lines that will be rendered. >>> Divider().rows((10,)) 1 >>> Divider(u'x', 1, 2).rows((10,)) 4 rE)r$r%©rXrIrRÚmaxcolr<r<r=r.Ós z Divider.rowscCs<|\}t|j|dƒ}t|ƒ}|js(|jr8| |j|j¡|S)a[ Render the divider as a canvas and return it. >>> Divider().render((10,)).text # ... = b in Python 3 [...' '] >>> Divider(u'-', top=1).render((10,)).text [...' ', ...'----------'] >>> Divider(u'x', bottom=2).render((5,)).text [...'xxxxx', ...' ', ...' '] rE)rr’rr$r%Zpad_trim_top_bottom©rXrIrRr—rJr<r<r=r-ßs  zDivider.renderN)r�rr)F)F) r>r?r@rAr}rqrlr/r2r„r…r.r-r<r<r<r=r�ªs   r�c@s4eZdZdZdZdZd dd„Zdd„Zd d d „Zd S)Ú SolidFillzA A box widget that fills an area with a single character FTr�cCs|j ¡||_dS)z© :param fill_char: character to fill area with :type fill_char: bytes or unicode >>> SolidFill(u'8') N)Ú_SolidFill__superr2Ú fill_char)rXr›r<r<r=r2ùs zSolidFill.__init__cCs|j ¡t|jƒgSrc)ršr„rr›rfr<r<r=r„szSolidFill._repr_wordscCs|\}}t|j||ƒS)zø Render the Fill as a canvas and return it. >>> SolidFill().render((4,2)).text # ... = b in Python 3 [...' ', ...' '] >>> SolidFill('#').render((5,3)).text [...'#####', ...'#####', ...'#####'] )rr›)rXrIrRr—Zmaxrowr<r<r=r-s zSolidFill.renderN)r�)F) r>r?r@rArjr/r2r„r-r<r<r<r=r™òs  r™c@s eZdZdS)Ú TextErrorNrDr<r<r<r=rœsrœc@sìeZdZdZeegƒZdZdZe e dfdd„Z dd„Z d d „Z d d „Zd d„Zdd„Zedd„dd�Zedd„dd�Zdd„Zdd„Zd+dd„Zedd„eƒZedd„eƒZedd„ƒZd,d!d"„Zd-d#d$„Zd.d%d&„Zd'd(„Zd/d)d*„ZdS)0ÚTextz/ a horizontally resizeable text widget TéŒNcCs,|j ¡d|_| |¡| |||¡dS)a[ :param markup: content of text widget, one of: bytes or unicode text to be displayed (*display attribute*, *text markup*) *text markup* with *display attribute* applied to all parts of *text markup* with no display attribute already applied [*text markup*, *text markup*, ... ] all *text markup* in the list joined together :type markup: :ref:`text-markup` :param align: typically ``'left'``, ``'center'`` or ``'right'`` :type align: text alignment mode :param wrap: typically ``'space'``, ``'any'``, ``'clip'`` or ``'ellipsis'`` :type wrap: text wrapping mode :param layout: defaults to a shared :class:`StandardTextLayout` instance :type layout: text layout instance >>> Text(u"Hello") >>> t = Text(('bold', u"stuff"), 'right', 'any') >>> t >>> print(t.text) stuff >>> t.attrib [('bold', 5)] N)Ú _Text__superr2Ú _cache_maxcolÚset_textÚ set_layout)rXÚmarkupÚalignÚwrapÚlayoutr<r<r=r2s  z Text.__init__cCsh|j ¡}| ¡d}t|ƒ}t|ƒ|jkr^|d|jddd…d||j dd…}||gS)z Show the text in the repr in python3 format (b prefix for byte strings) and truncate if it's too long rNééz...)rŸr„Úget_textrrGÚ_repr_content_length_max)rXÚfirstÚtextÚrestr<r<r=r„Ds  ÿÿzText._repr_wordscCs$t|j ¡|j|jd�}t|tjƒS)N)r¤r¥)r“rŸr…Ú _align_modeÚ _wrap_moderr�r2r”r<r<r=r…Qs  þzText._repr_attrscCsd|_|j ¡dSrc)r rŸrgrfr<r<r=rgWszText._invalidatecCst|ƒ\|_|_| ¡dS)aÌ Set content of text widget. :param markup: see :class:`Text` for description. :type markup: text markup >>> t = Text(u"foo") >>> print(t.text) foo >>> t.set_text(u"bar") >>> print(t.text) bar >>> t.text = u"baz" # not supported because text stores text but set_text() takes markup Traceback (most recent call last): AttributeError: can't set attribute N)rÚ_textÚ_attribrg©rXr£r<r<r=r¡[sz Text.set_textcCs |j|jfS)aV :returns: (*text*, *display attributes*) *text* complete bytes/unicode content of text widget *display attributes* run length encoded display attributes for *text*, eg. ``[('attr1', 10), ('attr2', 5)]`` >>> Text(u"Hello").get_text() # ... = u in Python 2 (...'Hello', []) >>> Text(('bright', u"Headline")).get_text() (...'Headline', [('bright', 8)]) >>> Text([('a', u"one"), u"two", ('b', u"three")]).get_text() (...'onetwothree', [('a', 3), (None, 3), ('b', 5)]) )r°r±rfr<r<r=r©osz Text.get_textcCs | ¡dS©Nr©r©rfr<r<r=rsƒrtz Text.zh Read-only property returning the complete bytes/unicode content of this widget rucCs | ¡dS)NrEr´rfr<r<r=rs‡rtzo Read-only property returning the run-length encoded display attributes of this widget cCs,|j |¡std|fƒ‚||_| ¡dS)a« Set text alignment mode. Supported modes depend on text layout object in use but defaults to a :class:`StandardTextLayout` instance :param mode: typically ``'left'``, ``'center'`` or ``'right'`` :type mode: text alignment mode >>> t = Text(u"word") >>> t.set_align_mode('right') >>> t.align 'right' >>> t.render((10,)).text # ... = b in Python 3 [...' word'] >>> t.align = 'center' >>> t.render((10,)).text [...' word '] >>> t.align = 'somewhere' Traceback (most recent call last): TextError: Alignment mode 'somewhere' not supported. z Alignment mode %r not supported.N)r¦Zsupports_align_moderœr®rg©rXÚmoder<r<r=Úset_align_modeŒs  ÿzText.set_align_modecCs,|j |¡std|fƒ‚||_| ¡dS)a Set text wrapping mode. Supported modes depend on text layout object in use but defaults to a :class:`StandardTextLayout` instance :param mode: typically ``'space'``, ``'any'``, ``'clip'`` or ``'ellipsis'`` :type mode: text wrapping mode >>> t = Text(u"some words") >>> t.render((6,)).text # ... = b in Python 3 [...'some ', ...'words '] >>> t.set_wrap_mode('clip') >>> t.wrap 'clip' >>> t.render((6,)).text [...'some w'] >>> t.wrap = 'any' # Urwid 0.9.9 or later >>> t.render((6,)).text [...'some w', ...'ords '] >>> t.wrap = 'somehow' Traceback (most recent call last): TextError: Wrap mode 'somehow' not supported. zWrap mode %r not supported.N)r¦Zsupports_wrap_moderœr¯rgrµr<r<r=Ú set_wrap_mode§s zText.set_wrap_modecCs,|durtj}||_| |¡| |¡dS)a Set the text layout object, alignment and wrapping modes at the same time. :type align: text alignment mode :param wrap: typically 'space', 'any', 'clip' or 'ellipsis' :type wrap: text wrapping mode :param layout: defaults to a shared :class:`StandardTextLayout` instance :type layout: text layout instance >>> t = Text(u"hi") >>> t.set_layout('right', 'clip') >>> t N)rZdefault_layoutÚ_layoutr·r¸)rXr¤r¥r¦r<r<r=r¢Ãs  zText.set_layoutcCs|jSrc)r®rfr<r<r=rsÙrtcCs|jSrc)r¯rfr<r<r=rsÚrtcCs|jSrc)r¹rfr<r<r=rsÛrtFcCs0|\}| ¡\}}| |||f¡}t||||ƒS)a` Render contents with wrapping and alignment. Return canvas. See :meth:`Widget.render` for parameter details. >>> Text(u"important things").render((18,)).text # ... = b in Python 3 [...'important things '] >>> Text(u"important things").render((11,)).text [...'important ', ...'things '] )r©Úget_line_translationr)rXrIrRr—r¬ÚattrÚtransr<r<r=r-Ýs  z Text.rendercCs|\}t| |¡ƒS)zø Return the number of rows the rendered text requires. See :meth:`Widget.rows` for parameter details. >>> Text(u"important things").rows((18,)) 1 >>> Text(u"important things").rows((11,)) 2 )rGrºr–r<r<r=r.îs z Text.rowscCs"|jr|j|kr| ||¡|jS)a¬ Return layout structure used to map self.text to a canvas. This method is used internally, but may be useful for debugging custom layout classes. :param maxcol: columns available for display :type maxcol: int :param ta: ``None`` or the (*text*, *display attributes*) tuple returned from :meth:`.get_text` :type ta: text and display attributes )r Ú_update_cache_translationÚ_cache_translation)rXr—Útar<r<r=rºüs  zText.get_line_translationcCs<|r|\}}n | ¡\}}||_|j |||j|j¡|_dSrc)r©r r¦r®r¯r¾)rXr—r¿r¬r»r<r<r=r½ s   ÿzText._update_cache_translationc Cs¸| ¡\}}|durT|\}t|jdƒs*|S| |||f¡}|j ||¡}|t|ƒfSd}d}|t|ƒkr¦| d|¡} | dkr„t|ƒ} t||| ƒ} | |krœ| }| d}q\|| d¡dfS)a Return the number of screen columns and rows required for this Text widget to be displayed without wrapping or clipping, as a single element tuple. :param size: ``None`` for unlimited screen columns or (*maxcol*,) to specify a maximum column size :type size: widget size >>> Text(u"important things").pack() (16, 1) >>> Text(u"important things").pack((15,)) (9, 2) >>> Text(u"important things").pack((8,)) (8, 2) Nr(rÚ éÿÿÿÿrE) r©r`r¦rºr(rGÚfindr Úcount) rXrIrRr¬r»r—r¼rFÚiÚjÚcr<r<r=r(s&       z Text.pack)N)F)F)N)NF)r>r?r@rAr}rqrlr/rªÚLEFTÚSPACEr2r„r…rgr¡r©r‡r¬Zattribr·r¸r¢r¤r¥r¦r-r.rºr½r(r<r<r<r=r�s. %       r�c@s eZdZdS)Ú EditErrorNrDr<r<r<r=rÉ=srÉc @s(eZdZdZdZdZddgZdd„Zdddee dd d d f d d „Z d d „Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zedd„dd�Zdd„Zed d„ed!d�Zd"d#„Zd$d%„Zd&d'„Zeeed(d�Zd)d*„Zd+d,„Zd-d.„Zd/d0„Zd1d2„Zd3d4„Zd5d6„Z d?d7d8„Z!d@d9d:„Z"d;d<„Z#d=d>„Z$d S)AÚEdita Text editing widget implements cursor movement, text insertion and deletion. A caption may prefix the editing area. Uses text class for text layout. Users of this class may listen for ``"change"`` or ``"postchange"`` events. See :func:``connect_signal``. * ``"change"`` is sent just before the value of edit_text changes. It receives the new text as an argument. Note that ``"change"`` cannot change the text in question as edit_text changes the text afterwards. * ``"postchange"`` is sent after the value of edit_text changes. It receives the old value of the text as an argument and thus is appropriate for changing the text. It is possible for a ``"postchange"`` event handler to get into a loop of changing the text and then being called when the event is re-emitted. It is up to the event handler to guard against this case (for instance, by not changing the text if it is signaled for for text that it has already changed once). TFÚchangeÚ postchangecCs"t|dƒp t|ƒdko t|ƒdkS)zê Filter for text that may be entered into this widget by the user :param ch: character to be inserted :type ch: bytes or unicode This implementation returns True for all printable characters. rrEé )r rGÚord©rXZchr<r<r=Ú valid_charZs zEdit.valid_charÚNc Csl|j d|||¡||_||_d|_| |¡d|_| |¡|durNt|ƒ}|  |¡|  | ¡d|_ dS)aõ :param caption: markup for caption preceding edit_text, see :class:`Text` for description of text markup. :type caption: text markup :param edit_text: initial text for editing, type (bytes or unicode) must match the text in the caption :type edit_text: bytes or unicode :param multiline: True: 'enter' inserts newline False: return it :type multiline: bool :param align: typically 'left', 'center' or 'right' :type align: text alignment mode :param wrap: typically 'space', 'any' or 'clip' :type wrap: text wrapping mode :param allow_tab: True: 'tab' inserts 1-8 spaces False: return it :type allow_tab: bool :param edit_pos: initial position for cursor, None:end of edit_text :type edit_pos: int :param layout: defaults to a shared :class:`StandardTextLayout` instance :type layout: text layout instance :param mask: hide text entered with this character, None:disable mask :type mask: bytes or unicode >>> Edit() >>> Edit(u"Y/n? ", u"yes") >>> Edit(u"Name ", u"Smith", edit_pos=1) >>> Edit(u"", u"3.14", align='right') rÑrNF) Ú _Edit__superr2Ú multilineÚ allow_tabÚ _edit_posÚ set_captionÚ _edit_textÚ set_edit_textrGÚ set_edit_posÚset_maskÚ_shift_view_to_cursor) rXÚcaptionÚ edit_textrÓr¤r¥rÔÚedit_posr¦Úmaskr<r<r=r2es#    z Edit.__init__cCsH|j ¡dd…t|jƒgdt|jƒgt|jƒdg|jduS)NrÁzcaption=rÓT)rÒr„rr×Ú_captionr[rÓrfr<r<r=r„•sÿ ÿÿÿÿÿþzEdit._repr_wordscCs t|j ¡|jd�}t|tjƒS)N)rÞ)r“rÒr…rÕrrÊr2r”r<r<r=r…›s ÿzEdit._repr_attrscCs<|jdur|j|j|jfS|j|jt|jƒ|jfSdS)aû Returns ``(text, display attributes)``. See :meth:`Text.get_text` for details. Text returned includes the caption and edit_text, possibly masked. >>> Edit(u"What? ","oh, nothing.").get_text() # ... = u in Python 2 (...'What? oh, nothing.', []) >>> Edit(('bright',u"user@host:~$ "),"ls").get_text() (...'user@host:~$ ls', [('bright', 13)]) >>> Edit(u"password:", u"seekrit", mask=u"*").get_text() (...'password:*******', []) N)Ú_maskràr×r±rGrfr<r<r=r© s z Edit.get_textcCs(t|dƒs|dkrd|_dStdƒ‚dS)zÛ Not supported by Edit widget. >>> Edit().set_text("test") Traceback (most recent call last): EditError: set_text() not supported. Use set_caption() or set_edit_text() instead. r°rÑNzHset_text() not supported. Use set_caption() or set_edit_text() instead.)r`r°rÉr²r<r<r=r¡´s z Edit.set_textcCs0|\}|j\}}||kr(| |f¡dS|SdS)a´ Return the preferred column for the cursor, or the current cursor x value. May also return ``'left'`` or ``'right'`` to indicate the leftmost or rightmost column available. This method is used internally and by other widgets when moving the cursor up or down between widgets so that the column selected is one that the user would expect. >>> size = (10,) >>> Edit().get_pref_col(size) 0 >>> e = Edit(u"", u"word") >>> e.get_pref_col(size) 4 >>> e.keypress(size, 'left') >>> e.get_pref_col(size) 3 >>> e.keypress(size, 'end') >>> e.get_pref_col(size) 'right' >>> e = Edit(u"", u"2\nwords") >>> e.keypress(size, 'left') >>> e.keypress(size, 'up') >>> e.get_pref_col(size) 4 >>> e.keypress(size, 'left') >>> e.get_pref_col(size) 0 rN)Úpref_col_maxcolÚget_cursor_coords)rXrIr—Úpref_colZ then_maxcolr<r<r=Ú get_pref_colÇs  zEdit.get_pref_colcCs tdƒ‚dS)zÕ No longer supported. >>> Edit().update_text() Traceback (most recent call last): EditError: update_text() has been removed. Use set_caption() or set_edit_text() instead. zNupdate_text() has been removed. Use set_caption() or set_edit_text() instead.N)rÉrfr<r<r=Ú update_textíszEdit.update_textcCst|ƒ\|_|_| ¡dS)au Set the caption markup for this widget. :param caption: markup for caption preceding edit_text, see :meth:`Text.__init__` for description of text markup. >>> e = Edit("") >>> e.set_caption("cap1") >>> print(e.caption) cap1 >>> e.set_caption(('bold', "cap2")) >>> print(e.caption) cap2 >>> e.attrib [('bold', 4)] >>> e.caption = "cap3" # not supported because caption stores text but set_caption() takes markup Traceback (most recent call last): AttributeError: can't set attribute N)rràr±rg)rXrÜr<r<r=rÖøszEdit.set_captioncCs|jSrc)ràrfr<r<r=rsrtz Edit.zK Read-only property returning the caption for this widget. rucCsB|dkr d}|t|jƒkr$t|jƒ}d|_d|_||_| ¡dS)aà Set the cursor position with a self.edit_text offset. Clips pos to [0, len(edit_text)]. :param pos: cursor position :type pos: int >>> e = Edit(u"", u"word") >>> e.edit_pos 4 >>> e.set_edit_pos(2) >>> e.edit_pos 2 >>> e.edit_pos = -1 # Urwid 0.9.9 or later >>> e.edit_pos 0 >>> e.edit_pos = 20 >>> e.edit_pos 4 rN©NN)rGr×Ú highlightrârÕrg)rXÚposr<r<r=rÙs zEdit.set_edit_poscCs|jSrc)rÕrfr<r<r=rs1rtzI Property controlling the edit position for this widget. cCs||_| ¡dS)z® Set the character for masking text away. :param mask: hide text entered with this character, None:disable mask :type mask: bytes or unicode N)rárg)rXrßr<r<r=rÚ5sz Edit.set_maskcCsX| |¡}d|_| d|¡|j}||_|jt|ƒkr@t|ƒ|_| d|¡| ¡dS)aß Set the edit text for this widget. :param text: text for editing, type (bytes or unicode) must match the text in the caption :type text: bytes or unicode >>> e = Edit() >>> e.set_edit_text(u"yes") >>> print(e.edit_text) yes >>> e >>> e.edit_text = u"no" # Urwid 0.9.9 or later >>> print(e.edit_text) no NrËrÌ)Ú_normalize_to_captionrèrir×rÞrGrg)rXr¬Zold_textr<r<r=rØ@s    zEdit.set_edit_textcCs|jS)z× Return the edit text for this widget. >>> e = Edit(u"What? ", u"oh, nothing.") >>> print(e.get_edit_text()) oh, nothing. >>> print(e.edit_text) oh, nothing. )r×rfr<r<r=Ú get_edit_text\s zEdit.get_edit_textzE Property controlling the edit text for this widget. cCs6| |¡}| |¡\}}| |¡| |¡d|_dS)aM Insert text at the cursor position and update cursor. This method is used by the keypress() method when inserting one or more characters into edit_text. :param text: text for inserting, type (bytes or unicode) must match the text in the caption :type text: bytes or unicode >>> e = Edit(u"", u"42") >>> e.insert_text(u".5") >>> e >>> e.set_edit_pos(2) >>> e.insert_text(u"a") >>> print(e.edit_text) 42a.5 N)rêÚinsert_text_resultrØrÙrè)rXr¬Ú result_textÚ result_posr<r<r=Ú insert_textls    zEdit.insert_textcCs:t|tƒ}t|jtƒ}||kr"|S|r0| d¡S| d¡S)zc Return text converted to the same type as self.caption (bytes or unicode) Úascii)Ú isinstancerràÚencodeÚdecode)rXr¬ZtuZcur<r<r=rê…s   zEdit._normalize_to_captioncCs¬| |¡}|jrF|j\}}|jd|…|j|d…}}||}|}n |j}|j}z |d|…|||d…}Wn$ds’Jt|j||fƒƒ‚Yn0|t|ƒ7}||fS)a! Return result of insert_text(text) without actually performing the insertion. Handy for pre-validation. :param text: text for inserting, type (bytes or unicode) must match the text in the caption :type text: bytes or unicode Nr)rêrèrÝrÞrprG)rXr¬ÚstartÚstopÚbtextÚetextrírîr<r<r=rì’s   ÿ zEdit.insert_text_resultcCsÈ|\}|j}| |¡rDt|tƒr6t|jtƒs6| d¡}| |¡�n€|dkrr|jrrdd|jd}| |¡�nR|dkr’|jr’d}| |¡�n2|j |t krÈ|dkr¬|St |j d|ƒ}|  |¡�nü|j |tk�r |t|j ƒkrê|St|j |t|j ƒƒ}|  |¡�n¸|j |ttfv�rŒd|_| |f¡\}}| |f¡}|du�sPJ‚|j |tk�rj|d 8}n|d 7}| |f||¡�sÄ|S�n8|d k�ròd |_| ¡�sÄ|dk�r´|St |j d|ƒ}| |j d|…|j |jd…¡|  |¡nÒ|d k�rZd |_| ¡�sÄ|t|j ƒk�r |St|j |t|j ƒƒ}| |j d|j…|j |d…¡nj|j |ttfv�rÀd|_d |_| |f¡\}}|j |tk�r¬| |ft|¡n| |ft|¡dS|SdS) aÉ Handle editing keystrokes, return others. >>> e, size = Edit(), (20,) >>> e.keypress(size, 'x') >>> e.keypress(size, 'left') >>> e.keypress(size, '1') >>> print(e.edit_text) 1x >>> e.keypress(size, 'backspace') >>> e.keypress(size, 'end') >>> e.keypress(size, '2') >>> print(e.edit_text) x2 >>> e.keypress(size, 'shift f1') 'shift f1' zutf-8Ztabr�éZenterrÀrNrEZ backspacerçÚdelete)rÞrÐrñrràròrïrÔrÓr†rr rÝrÙrrGr rrrèrãråÚmove_cursor_to_coordsrâÚ_delete_highlightedrØrrrÇÚRIGHT)rXrIÚkeyr—ÚpÚxÚyrär<r<r=Úkeypress¯st   ÿ     ÿ    ÿz Edit.keypressc Csœ|\}| |¡}| |d¡\}}||ks4|t|ƒkr8dSt| ¡d|||ƒ}|t|jƒ} | dkrhd} | t|jƒkr€t|jƒ} | |_||f|_|  ¡dS)a´ Set the cursor position with (x,y) coordinates. Returns True if move succeeded, False otherwise. >>> size = (10,) >>> e = Edit("","edit\ntext") >>> e.move_cursor_to_coords(size, 5, 0) True >>> e.edit_pos 4 >>> e.move_cursor_to_coords(size, 5, 3) False >>> e.move_cursor_to_coords(size, 0, 1) True >>> e.edit_pos 5 rFT) rºÚposition_coordsrGr r©rÜrÝrÞrârg) rXrIrÿrr—r¼Ztop_xZtop_yréZe_posr<r<r=rús   zEdit.move_cursor_to_coordscCs"|\}|dkr| |f||¡SdS)zó Move the cursor to the location clicked for button 1. >>> size = (20,) >>> e = Edit("","words here") >>> e.mouse_event(size, 'mouse press', 1, 2, 0, True) True >>> e.edit_pos 2 rEN©rú)rXrIZeventZbuttonrÿrrRr—r<r<r=Ú mouse_event1s zEdit.mouse_eventcCsP|js dS|j\}}|jd|…|j|d…}}| ||¡||_d|_dS)zm Delete all highlighted text and update cursor position, if any text is highlighted. NT)rèrÝrØrÞ)rXrôrõrör÷r<r<r=rûAs  zEdit._delete_highlightedcCs<|\}t|ƒ|_t ||f¡}|r8t|ƒ}| |f¡|_|S)a Render edit widget and return canvas. Include cursor when in focus. >>> c = Edit("? ","yes").render((10,), focus=True) >>> c.text # ... = b in Python 3 [...'? yes '] >>> c.cursor (5, 0) )r[rÛr�r-rrãZcursorr˜r<r<r=r-Os  z Edit.rendercCs¸t |||¡}|js|S| ¡\}}t|||jt|jƒƒ\}}|dkrv|d|…t||| ƒg||dd…S||kr´|d|…t||||d ƒg||dd…S|S)NrrE) r�rºrÛr©rrÞrGrÜr)rXr—r¿r¼r¬Úignorerÿrr<r<r=rºis( ÿ ÿþ ÿþzEdit.get_line_translationcCs|\}d|_| ||j¡S)z’ Return the (*x*, *y*) coordinates of cursor within widget. >>> Edit("? ","yes").get_cursor_coords((10,)) (5, 0) T)rÛrrÞ)rXrIr—r<r<r=rã|szEdit.get_cursor_coordscCs8|t|jƒ}| |¡}t| ¡d||ƒ\}}||fS)zR Return (*x*, *y*) coordinates for an offset into self.edit_text. r)rGrÜrºrr©)rXr—rérþr¼rÿrr<r<r=r‰s zEdit.position_coords)F)N)%r>r?r@rArjr/rrÐrÇrÈr2r„r…r©r¡rårærÖr‡rÜrÙrÞrÚrØrërÝrïrêrìrrúrrûr-rºrãrr<r<r<r=rÊAsD þ 0&    a!   rÊc@s2eZdZdZdd„Zd dd„Zdd „Zd d „ZdS) ÚIntEditzEdit widget for integer valuescCst|ƒdko|dvS)z1 Return true for decimal digits. rEÚ 0123456789)rGrÏr<r<r=rЗszIntEdit.valid_charrÑNcCs(|durt|ƒ}nd}|j ||¡dS)z¨ caption -- caption markup default -- default edit value >>> IntEdit(u"", 42) NrÑ)ÚstrZ_IntEdit__superr2)rXrÜÚdefaultryr<r<r=r2�szIntEdit.__init__cCs`|\}t ||f|¡}|s\|jdkr\|jdd…dkr\| |jd¡| |jdd…¡q|S)a8 Handle editing keystrokes. Remove leading zeros. >>> e, size = IntEdit(u"", 5002), (10,) >>> e.keypress(size, 'home') >>> e.keypress(size, 'delete') >>> print(e.edit_text) 002 >>> e.keypress(size, 'end') >>> print(e.edit_text) 2 rNrEÚ0)rÊrrÞrÝrÙrØ)rXrIrýr—Z unhandledr<r<r=r©s zIntEdit.keypresscCs|jrt|jƒSdSdS)zÒ Return the numeric value of self.edit_text. >>> e, size = IntEdit(), (10,) >>> e.keypress(size, '5') >>> e.keypress(size, '1') >>> e.value() == 51 True rN)rÝÚintrfr<r<r=ÚvalueÁs  z IntEdit.value)rÑN)r>r?r@rArÐr2rr r<r<r<r=r”s  rcs t|ƒ‰G‡fdd„dtƒ}|S)zÀ Return a mixin class that delegates all standard widget methods to an attribute given by attribute_name. This mixin is designed to be used as a superclass of another widget. cs°eZdZdgZd‡fdd„ Ze‡fdd„ƒZe‡fdd„ƒZe‡fdd„ƒZe‡fd d„ƒZ e‡fd d„ƒZ e‡fd d„ƒZ e‡fd d„ƒZ e‡fd d„ƒZ e‡fdd„ƒZdS)z7delegate_to_widget_mixin..DelegateToWidgetMixinr.Fcsˆ|ƒj||d�}t|ƒSrQ)r-rrW©Z get_delegater<r=r-ßsz>delegate_to_widget_mixin..DelegateToWidgetMixin.rendercs ˆ|ƒjSrc)rkrfr r<r=rsãrtz@delegate_to_widget_mixin..DelegateToWidgetMixin.cs ˆ|ƒjSrc)rãrfr r<r=rsårtcs ˆ|ƒjSrc)rårfr r<r=rsærtcs ˆ|ƒjSrc)rrfr r<r=rsçrtcs ˆ|ƒjSrcrrfr r<r=rsértcs ˆ|ƒjSrc)r.rfr r<r=rsêrtcs ˆ|ƒjSrc)rrfr r<r=rsërtcs ˆ|ƒjSrc)rmrfr r<r=rsìrtcs ˆ|ƒjSrc)r(rfr r<r=rsírtN)F)r>r?r@r,r-r‡rkrãrårrúr.rrmr(r<r r<r=ÚDelegateToWidgetMixinÜs ÿ ÿr)rre)Zattribute_namerr<r r=Údelegate_to_widget_mixinÑs rc@s eZdZdS)ÚWidgetWrapErrorNrDr<r<r<r=ròsrc@s>eZdZdd„Zdd„Zedd„eƒZd dd „ZeeeƒZdS) Ú WidgetWrapcCs ||_dS)a9 w -- widget to wrap, stored as self._w This object will pass the functions defined in Widget interface definition to self._w. The purpose of this widget is to provide a base class for widgets that compose other widgets for their display and behaviour. The details of that composition should not affect users of the subclass. The subclass may decide to expose some of the wrapped widgets by behaving like a ContainerWidget or WidgetDecoration, or it may hide them from outside access. N©Ú_wrapped_widget©rXÚwr<r<r=r2öszWidgetWrap.__init__cCs||_| ¡dS)aÄ Change the wrapped widget. This is meant to be called only by subclasses. >>> size = (10,) >>> ww = WidgetWrap(Edit("hello? ","hi")) >>> ww.render(size).text # ... = b in Python 3 [...'hello? hi '] >>> ww.selectable() True >>> ww._w = Text("goodbye") # calls _set_w() >>> ww.render(size).text [...'goodbye '] >>> ww.selectable() False N)rrgrr<r<r=Ú_set_wszWidgetWrap._set_wcCs|jSrcrrfr<r<r=rsrtzWidgetWrap.NcCs tdƒ‚dS)NzºThe WidgetWrap.w member variable has been renamed to WidgetWrap._w (not intended for use outside the class and its subclasses). Please update your code to use self._w instead of self.w.)rrxr<r<r=Ú_raise_old_name_errorsz WidgetWrap._raise_old_name_error)N) r>r?r@r2rr‡Z_wrrr<r<r<r=rõs  rrcCsddl}| ¡dSr³)ÚdoctestZtestmod)rr<r<r=Ú_test%srÚ__main__N)UZ __future__rrÚoperatorrZ urwid.compatrrZ urwid.utilrrr r r r Zurwid.text_layoutr rrZurwidrrZ urwid.canvasrrrrZurwid.command_maprrrrrrrZurwid.split_reprrrrrqr~rnrÇrüZCENTERZTOPZMIDDLEZBOTTOMrÈÚANYZCLIPÚELLIPSISZPACKZGIVENZRELATIVEZ RELATIVE_100ZWEIGHTZ MetaSignalsr+Ú ExceptionrCrKrPr3r4rbr5Úobjectrerˆr‹r�rŽr�r™rœr�rÉrÊrrrrrr>r<r<r<r=Ús|    $!  H!)W=!0