
    jj6                    ~    d dl mZ d dlZd dlZddlmZ ej                  rd dlmZ ddl	m
Z
 ddlmZ  G d d	e      Zy)
    )annotationsN   )AttrMap)Hashable)Sizing)Widgetc                       e Zd Zdd fdZd fdZedd       Zej                  dd       Zd ZddZ	ddZ
ddZ ee
e      Zdd	Zdd
Z eee      ZddZddZ xZS )AttrWrapc                `    t        j                  dt        d       t        |   |||       y)a,  
        w -- widget to wrap (stored as self.original_widget)
        attr -- attribute to apply to w
        focus_attr -- attribute to apply when in focus, if None use attr

        This widget is a special case of the new AttrMap widget, and it
        will pass all function calls and variable references to the wrapped
        widget.  This class is maintained for backwards compatibility only,
        new code should use AttrMap instead.

        >>> from urwid import Divider, Edit, Text
        >>> AttrWrap(Divider("!"), "bright")
        <AttrWrap flow widget <Divider flow widget '!'> attr='bright'>
        >>> AttrWrap(Edit(), "notfocus", "focus")
        <AttrWrap selectable flow widget <Edit selectable flow widget '' edit_pos=0> attr='notfocus' focus_attr='focus'>
        >>> size = (5,)
        >>> aw = AttrWrap(Text("hi"), "greeting", "fgreet")
        >>> next(aw.render(size, focus=False).content())
        [('greeting', None, ...'hi   ')]
        >>> next(aw.render(size, focus=True).content())
        [('fgreet', None, ...'hi   ')]
        z]AttrWrap is maintained for backwards compatibility only, new code should use AttrMap instead.   
stacklevelN)warningswarnPendingDeprecationWarningsuper__init__)selfwattr
focus_attr	__class__s       _/home/ubuntu/.cache/pipx/cdb5059130eadca/lib/python3.12/site-packages/urwid/widget/attr_wrap.pyr   zAttrWrap.__init__   s-    . 	k%	

 	D*-    c                    i t         |          d| j                  i}|d= |j                  dd        | j                  | j                  |d<   |S )Nr   attr_map	focus_mapr   )r   _repr_attrsr   popr   )r   dr   s     r   r   zAttrWrap._repr_attrs.   sQ    8uw"$8fdii8jM	k4 ??&"ooAlOr   c                R    t        j                  dt        d       | j                  S )z6backwards compatibility, widget used to be stored as wibackwards compatibility, widget used to be stored as original_widget. API will be removed in version 5.0.r   r   r   r   DeprecationWarningoriginal_widgetr   s    r   r   z
AttrWrap.w7   s'     	w	

 ###r   c                J    t        j                  dt        d       || _        y )Nr"   r   r   r#   r   
new_widgets     r   r   z
AttrWrap.wA   s!    w	

  *r   c                R    t        j                  dt        d       | j                  S Nzibackwards compatibility, widget used to be stored as original_widget. API will be removed in version 4.0.r   r   r#   r&   s    r   get_wzAttrWrap.get_wJ   s%    w	

 ###r   c                J    t        j                  dt        d       || _        y r+   r#   r(   s     r   set_wzAttrWrap.set_wR   s!    w	

  *r   c                     | j                   d    S N)r   r&   s    r   get_attrzAttrWrap.get_attrZ   s    }}T""r   c                *    | j                  d|i       y)z
        Set the attribute to apply to the wrapped widget

        >> w = AttrWrap(Divider("-"), None)
        >> w.set_attr('new_attr')
        >> w
        <AttrWrap flow widget <Divider flow widget '-'> attr='new_attr'>
        N)set_attr_map)r   r   s     r   set_attrzAttrWrap.set_attr]   s     	4,'r   c                *    | j                   x}r|d    S y r0   )r   )r   r   s     r   get_focus_attrzAttrWrap.get_focus_attrj   s    &9&T?"r   c                *    | j                  d|i       y)a  
        Set the attribute to apply to the wapped widget when it is in
        focus

        If None this widget will use the attr instead (no change when in
        focus).

        >> w = AttrWrap(Divider("-"), 'old')
        >> w.set_focus_attr('new_attr')
        >> w
        <AttrWrap flow widget <Divider flow widget '-'> attr='old' focus_attr='new_attr'>
        >> w.set_focus_attr(None)
        >> w
        <AttrWrap flow widget <Divider flow widget '-'> attr='old'>
        N)set_focus_map)r   r   s     r   set_focus_attrzAttrWrap.set_focus_attro   s      	D*-.r   c                .    t        | j                  |      S )z
        Call getattr on wrapped widget.  This has been the longstanding
        behaviour of AttrWrap, but is discouraged.  New code should be
        using AttrMap and .base_widget or .original_widget instead.
        )getattr_original_widget)r   names     r   __getattr__zAttrWrap.__getattr__   s     t,,d33r   c                6    | j                   j                         S r0   )r<   sizingr&   s    r   r@   zAttrWrap.sizing   s    $$++--r   r0   )r   r   )returnzdict[str, typing.Any])rA   r   )r)   r   rA   None)rA   r   )r   r   rA   rB   )rA   zHashable | None)r   r   rA   rB   )r=   str)rA   zfrozenset[Sizing])__name__
__module____qualname__r   r   propertyr   setterr,   r.   r1   r4   r   r6   r9   r   r>   r@   __classcell__)r   s   @r   r
   r
      s}    .< $ $ XX* *$*#	( Hh'D
/$ ..9J4.r   r
   )
__future__r   typingr   r   r   TYPE_CHECKINGcollections.abcr   	constantsr   widgetr   r
    r   r   <module>rQ      s1    "   	(!}.w }.r   