
    jjFg                       d dl mZ d dlZd dlZd dlZd dlZd dlmZ d dlm	Z	 d dl
mZmZmZ d dlmZ d dlmZ d dlmZ d	d
lmZ ej,                  rd dlmZmZ  ej4                  d      Z ej8                  e      Z G d de	j>                  e      Z  G d de!      Z" G d de#      Z$d Z%d Z&d Z'd Z(d Z) G d de       Z*d$dZ+d%dZ, G d de!      Z- G d d  e,d!      ej\                  e         Z/d" Z0ed#k(  r e0        yy)&    )annotationsN)
attrgetter)signals)CanvasCanvasCacheCompositeCanvas)command_map
split_repr)	MetaSuper   )Sizing)CallableHashableWrappedWidgetc                  "     e Zd ZdZ fdZ xZS )
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.
    c                    |j                  dg       }t        | 	  |||       d|v r"d|vrt        |       }nt	        |       }|| _        d|v rd|vrt        |       | _        d|v r| `d|v r| `	y y )Nno_cacherenderrowsignore_focus)
getsuper__init__cache_widget_rendernocache_widget_renderr   cache_widget_rowsr   r   r   )clsnamebasesdr   	render_fn	__class__s         \/home/ubuntu/.cache/pipx/cdb5059130eadca/lib/python3.12/site-packages/urwid/widget/widget.pyr   zWidgetMeta.__init__;   s    55R(ua(q=x'/4	1#6	"CJQ;61(-CH?Q      )__name__
__module____qualname____doc__r   __classcell__r$   s   @r%   r   r   ,   s    ! !r&   r   c                      e Zd ZdZy)WidgetErrorzWidget specific errors.Nr'   r(   r)   r*    r&   r%   r.   r.   O   s    !r&   r.   c                      e Zd ZdZy)WidgetWarningzWidget specific warnings.Nr/   r0   r&   r%   r2   r2   S   s    #r&   r2   c                    |r|dd dk7  r|d   |j                         k7  s$t        |      dkD  rM|d   |j                         k7  r6t        d| d|j                         dd|j                         dd	|d
	      yy)z<
    Raise a WidgetError if a canv does not match size.
    r   N)r   r   Widget z rendered (r"   z x z) canvas when passed size !)colslenr   r.   )widgetsizecanvs      r%   validate_sizer;   W   s     	abT!d1g&<#d)a-TXYZT[_c_h_h_jTjfZ{499;q/TYY[OKefjemmno
 	
 Uk-r&   c                     t        t         dd             j                  t        j                        d fd	       }|_        |S )zt
    Return a function that wraps the cls.render() method
    and fetches and stores canvases with CanvasCache.
    r   Fc                    |xr  }t        j                  | ||      x}r|S  | ||      }t        | ||       |j                  rt	        |      }|j                  | ||       t        j                  |       |S N)focus)r   fetchr;   widget_infor   finalizestoreselfr9   r?   r:   r   fnr   s       r%   cached_renderz*cache_widget_render.<locals>.cached_renderi   s    *l*$$T3e<<4<K$E*dD$'"4(DdD%(#t$r&   F)boolgetattrr   	functoolswrapsoriginal_fn)r   rG   rF   r   s   ` @@r%   r   r   a   sL    
 ^U;<L	B__R  !#Mr&   c                    | j                   t        d      rj                  t        j                        dfd	       }|_        |S )zl
    Return a function that wraps the cls.render() method
    and finalizes the canvas that it returns.
    rM   c                     | ||      }|j                   rt        |      }t        | ||       |j                  | ||       |S r>   )rA   r   r;   rB   )rE   r9   r?   r:   rF   s       r%   finalize_renderz.nocache_widget_render.<locals>.finalize_render   sE    $E*"4(DdD$'dD%(r&   rH   )r   hasattrrM   rK   rL   )r   rP   rF   s     @r%   r   r   |   sL    
 
Br=!^^__R  #%Or&   c                      j                   j                  t        j                        d fd	       }|_        |S )z
    Return a function that wraps the cls.render() method
    and finalizes the canvas that it returns, but does not
    cache the canvas.
    c                r     | |      }|j                   rt        |      }|j                  | |       |S r>   )rA   r   rB   )r9   r?   r:   rF   rE   s      r%   rP   z7nocache_widget_render_instance.<locals>.finalize_render   s9    $E*"4(DdD%(r&   rH   )r   rM   rK   rL   )rE   rP   rF   s   ` @r%   nocache_widget_render_instancerT      s?     
	 	 B__R  #%Or&   c                     t        t         dd             j                  t        j                        dd fd       }|S )zt
    Return a function that wraps the cls.rows() method
    and returns rows from the CanvasCache if available.
    r   Fc                z    |xr  }t        j                  | ||      x}r|j                         S  | ||      S N)r   r@   r   rD   s       r%   cached_rowsz&cache_widget_rows.<locals>.cached_rows   sG    *l*$$T3e<<4<99;$e$$r&   rH   )r9   z
tuple[int]r?   rI   returnint)rI   rJ   r   rK   rL   )r   rX   rF   r   s   ` @@r%   r   r      sD    
 ^U;<L	B__R% % r&   c                  B   e Zd ZdZdZ eej                  ej                  ej                  g      Z
eZddZddZddZddZddZdddZedd	       Zedd
       ZddZ eeed      Zd ZddZddZ	 	 	 	 	 	 d dZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 d!dZ	 d	 	 	 	 	 d"dZy)#Widgeta  
    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:: 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:: 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
    Fc                    t        j                  | j                  j                   d| j                  j                         | _        y )N.)logging	getLoggerr$   r(   r'   loggerrE   s    r%   r   zWidget.__init__-  s5    ''4>>+D+D*EQt~~G^G^F_(`ar&   c                .    t        j                  |        y)zZMark cached canvases rendered by this widget as dirty so that they will not be used again.N)r   
invalidaterb   s    r%   _invalidatezWidget._invalidate0  s    t$r&   c                4    t        j                  | || g|  y)zAConvenience function to emit signals with self as first argument.N)r   emit_signal)rE   r    argss      r%   _emitzWidget._emit4  s    D$4t4r&   c                    | j                   S )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).
        )_selectablerb   s    r%   
selectablezWidget.selectable8  s    & r&   c                    | j                   S )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.
        )_sizingrb   s    r%   sizingzWidget.sizingM  s    < ||r&   c                (   |s<t         j                  | j                         v rt        | d      t	        d|       t        |      dk(  rEt         j                  | j                         v rg || j                  ||      S t	        d|       |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 must override Widget.pack()z1Cannot pack () size, this is not a fixed widget: r   z7Cannot pack (maxcol,) size, this is not a flow widget: )r   FIXEDro   NotImplementedErrorr.   r7   FLOWr   rE   r9   r?   s      r%   packzWidget.packm  s    6 ||t{{},)TH4P*QRR QRVQYZ[[t9>{{dkkm+66tyyu566 WX\W_`aar&   c                    | S )zRead-only property that steps through decoration widgets and returns the one at the base.

        This default implementation returns self.
        r0   rb   s    r%   base_widgetzWidget.base_widget  s	     r&   c                     y)z
        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.
        Nr0   rb   s    r%   r?   zWidget.focus  s     r&   Nc                     t        d| d      )NzNo focus_position, z is not a container widget)
IndexError)rE   vals     r%   _not_a_containerzWidget._not_a_container  s    .th6PQRRr&   a  
        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.
        )docc                    t        |       S )zA friendly __repr__ for widgets.

        Designed to be extended by subclasses with _repr_words and _repr_attr methods.
        r
   rb   s    r%   __repr__zWidget.__repr__  s    
 $r&   c                \   g }| j                         rdg|}| j                         r| j                         t        t        j                  t        j
                  t        j                  g      k7  r7|j                  dj                  t        | j                                            g |dS )Nrl   /r8   )
rl   ro   	frozensetr   rs   BOXrq   appendjoinsorted)rE   wordss     r%   _repr_wordszWidget._repr_words  s    ??!*E*E;;=T[[]ifjjRXR^R^8_.``LL&"789!!!!r&   c                    i S rW   r0   rb   s    r%   _repr_attrszWidget._repr_attrs  s    	r&   c                   | j                         syt        | d      r | j                  j                  d|        |S t	        j
                  d| j                  j                   dt        d       t        j                  d| d       |S )a|  Keyboard input handler.

        :param size: See :meth:`Widget.render` for details
        :type size: tuple[()] | tuple[int] | tuple[int, int]
        :param key: a single keystroke value; see :ref:`keyboard-input`
        :type key: str
        :return: ``None`` if *key* was handled by *key* (the same value passed) if *key* was not handled
        :rtype: str | None
        ra   z'keypress sent to non selectable widget r4   z! did not call 'super().__init__()   
stacklevel is not selectable
rl   rQ   ra   debugwarningswarnr$   r'   r2   LOGGER)rE   r9   keys      r%   keypresszWidget.keypress  s      tX&!!$KD8"TU 
 dnn5566WX! 
 wth.@AB
r&   c                   | j                         syt        | d      r | j                  j                  d| d       yt	        j
                  d| j                  j                   dt        d       t        j                  d| d       y)a  Mouse event handler.

        :param size: See :meth:`Widget.render` for details.
        :type size: tuple[()] | tuple[int] | tuple[int, int]
        :param event: Values such as ``'mouse press'``, ``'ctrl mouse press'``,
                     ``'mouse release'``, ``'meta mouse release'``,
                     ``'mouse drag'``; see :ref:`mouse-input`
        :type event: str
        :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
        :return: ``True`` if the event was handled by this widget, ``False`` otherwise
        :rtype: bool | None
        ra   r4   r   z not called 'super().__init__()r   r   Fr   )rE   r9   eventbuttoncolrowr?   s          r%   mouse_eventzWidget.mouse_event  s    :  tX&!!GD83E"FG  dnn5566UV! 
 wth.@ABr&   c                    t         )aP  Render widget and produce canvas

        :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.
        )rr   rt   s      r%   r   zWidget.render	  s    X "!r&   )rY   None)r    r   rY   r   )rY   rI   )rY   zfrozenset[Sizing]rH   )r9   (tuple[()] | tuple[int] | tuple[int, int]r?   rI   rY   ztuple[int, int])rY   r\   )rY   zWidget | NonerW   )rY   z	list[str])rY   zdict[str, typing.Any]r9   r   r   strrY   z
str | None)r9   r   r   r   r   rZ   r   rZ   r   rZ   r?   rI   rY   zbool | None)r9   r   r?   rI   rY   r   )r'   r(   r)   r*   rk   r   r   rs   r   rq   rn   r	   _command_mapr   re   ri   rl   ro   ru   propertyrw   r?   r|   focus_positionr   r   r   r   r   r   r0   r&   r%   r\   r\      s8   l\ Kfjj&,,?@GLb%5 *@&P    S 	N "6  
	4'6' ' 	'
 ' ' ' 
'X ,"6," ," 
	,"r&   r\   )	metaclassc                $    | rt        d|       y)z[
    raise ValueError if size != ().

    Used by FixedWidgets to test size parameter.
    z+FixedWidget takes only () for size.passed: N)
ValueError)r9   s    r%   
fixed_sizer   8  s     FthOPP r&   c                @    t        |        G fddt              }|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.
    c                      e Zd ZU dgZded<   dd fdZed fd       Zed fd       Zed fd       Z	d fdZ
ed fd	       Zed fd
       Ze	 	 d fd       Zed fd       Zed fd       Zy)7delegate_to_widget_mixin.<locals>.DelegateToWidgetMixinr   ztyping.ClassVar[list[str]]r   c                L     |       j                  ||      }t        |      S r>   )r   r   )rE   r9   r?   r:   get_delegates       r%   r   z>delegate_to_widget_mixin.<locals>.DelegateToWidgetMixin.renderQ  s(    %,,T,?D"4((r&   c                (     |       j                   S rW   )rl   rE   r   s    r%   rl   zBdelegate_to_widget_mixin.<locals>.DelegateToWidgetMixin.selectableU  s    %000r&   c                (     |       j                   S rW   )get_cursor_coordsr   s    r%   r   zIdelegate_to_widget_mixin.<locals>.DelegateToWidgetMixin.get_cursor_coordsY  s      %777r&   c                (     |       j                   S rW   )get_pref_colr   s    r%   r   zDdelegate_to_widget_mixin.<locals>.DelegateToWidgetMixin.get_pref_col^  s      %222r&   c                4     |       j                  ||      S rW   )r   )rE   r9   r   r   s      r%   r   z@delegate_to_widget_mixin.<locals>.DelegateToWidgetMixin.keypressc  s    %..tS99r&   c                (     |       j                   S rW   )move_cursor_to_coordsr   s    r%   r   zMdelegate_to_widget_mixin.<locals>.DelegateToWidgetMixin.move_cursor_to_coordsf  s      %;;;r&   c                (     |       j                   S rW   )r   r   s    r%   r   z<delegate_to_widget_mixin.<locals>.DelegateToWidgetMixin.rowsk      %***r&   c                (     |       j                   S rW   )r   r   s    r%   r   zCdelegate_to_widget_mixin.<locals>.DelegateToWidgetMixin.mouse_evento  s    
  %111r&   c                (     |       j                   S rW   )ro   r   s    r%   ro   z>delegate_to_widget_mixin.<locals>.DelegateToWidgetMixin.sizingv  s    %,,,r&   c                (     |       j                   S rW   )ru   r   s    r%   ru   z<delegate_to_widget_mixin.<locals>.DelegateToWidgetMixin.packz  r   r&   NrH   )r?   rI   rY   r   )rY   zCallable[[], bool])rY   zLCallable[[tuple[()] | tuple[int] | tuple[int, int]], tuple[int, int] | None])rY   z@Callable[[tuple[()] | tuple[int] | tuple[int, int]], int | None]r   )rY   zFCallable[[[tuple[()] | tuple[int] | tuple[int, int], int, int]], bool])rY   z!Callable[[tuple[int], bool], int])rY   z[Callable[[tuple[()] | tuple[int] | tuple[int, int], str, int, int, int, bool], bool | None])rY   zCallable[[], frozenset[Sizing]])rY   zKCallable[[tuple[()] | tuple[int] | tuple[int, int], bool], tuple[int, int]])r'   r(   r)   r   __annotations__r   r   rl   r   r   r   r   r   r   ro   ru   )r   s   r%   DelegateToWidgetMixinr   N  s    06x,7	) 
	1 
	1 
	8 
	8 
	3 
	3	: 
	< 
	< 
	+ 
	+ 
	2h	2 
	2 
	- 
	- 
	+ 
	+r&   r   )r   r\   )attribute_namer   r   s     @r%   delegate_to_widget_mixinr   B  s$     n-L.+ .+` ! r&   c                      e Zd Zy)WidgetWrapErrorN)r'   r(   r)   r0   r&   r%   r   r     s    r&   r   c                  `     e Zd Zd fdZedd       Zej                  dd       ZddZ xZS )
WidgetWrapc                    t         |           t        |t              sN|j                  j
                   d|j                  j                   }t        j                  | dt        d       || _
        y)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.
        r^   z is not subclass of Widget   r   N)r   r   
isinstancer\   r$   r(   r'   r   r   DeprecationWarning_wrapped_widget)rE   wobj_class_pathr$   s      r%   r   zWidgetWrap.__init__  sh     	!V$ ! 6 67q9M9M8NONMM!""<="
  !r&   c                    | j                   S rW   )r   rb   s    r%   _wzWidgetWrap._w  s    ###r&   c                2    || _         | j                          y)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)r   re   )rE   
new_widgets     r%   r   zWidgetWrap._w  s    $  *r&   c                j    t        j                  dt        d       || _        | j	                          y)a  
        Change the wrapped widget.  This is meant to be called
        only by subclasses.
        >>> from urwid import Edit, Text
        >>> 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
        zg_set_w is deprecated. Please use 'WidgetWrap._w' property directly. API will be removed in version 5.0.r   r   N)r   r   r   r   re   )rE   r   s     r%   _set_wzWidgetWrap._set_w  s/    " 	u	

  !r&   )r   r   rY   r   )rY   r   )r   r   rY   r   )	r'   r(   r)   r   r   r   setterr   r+   r,   s   @r%   r   r     s9    !0 $ $ YY (r&   r   r   c                 ,    dd l } | j                          y )Nr   )doctesttestmod)r   s    r%   _testr     s    OOr&   __main__)r9   z	tuple[()]rY   r   )r   r   rY   ztype[Widget])1
__future__r   rK   r_   typingr   operatorr   urwidr   urwid.canvasr   r   r   urwid.command_mapr	   urwid.split_reprr   
urwid.utilr   	constantsr   TYPE_CHECKINGcollections.abcr   r   TypeVarr   r`   r'   r   MetaSignalsr   	Exceptionr.   Warningr2   r;   r   r   rT   r   r\   r   r   r   Genericr   r   r0   r&   r%   <module>r      s  * #       = = ) '   	2/			8	$ !$$i  !F") "$G $
6,(({"z {"|Q<!~	i 	I)*;<fnn]>[ IX z	G r&   