Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
attr_map.cpython-313.pyc85 linesDownload Raw Back to __pycache__
1�

2��j=���SSKJr SSKrSSKJrJr SSKJr SSKJ	r	J3r4 SSKJr \R"S5r"S	S5\	5r"SS\6"S
5\\5rg)�)�annotationsN)�Hashable�Mapping)�CompositeCanvas�)�WidgetError�delegate_to_widget_mixin)�WidgetDecoration�
WrappedWidgetc��\rSrSrSrg)�AttrMapError��N)�__name__�7__module__�__qualname__�__firstlineno__�__static_attributes__r��[D:\code\apps\devtools\python\user_packages\Python313\site-packages\urwid/widget/attr_map.pyr
r
s��rr
c�^�\rSrSrSrSSU4SjjjrS
U4SjjrSSjrSSjr\	"\\5r8SSjrSSjr\	"\\5r
SSS	jjrS9rU=r$)�AttrMap�z�10AttrMap is a decoration that maps one set of attributes to another.11This object will pass all function calls and variable references to the12wrapped widget.13c��>�[TU]U5 [U[5(a[	U5UlO	SU0Ul[U[5(a[	U5UlgUcX0lgSU0Ulg)a�14:param w: widget to wrap (stored as self.original_widget)15:type w: widget16 17:param attr_map: attribute to apply to *w*, or dict of old display18    attribute: new display attribute mappings19:type attr_map: display attribute or dict20 21:param focus_map: attribute to apply when in focus or dict of22    old display attribute: new display attribute mappings;23    if ``None`` use *attr*24:type focus_map: display attribute or dict25 26>>> from urwid import Divider, Edit, Text27>>> AttrMap(Divider("!"), "bright")28<AttrMap flow widget <Divider flow widget '!'> attr_map={None: 'bright'}>29>>> AttrMap(Edit(), "notfocus", "focus").attr_map30{None: 'notfocus'}31>>> AttrMap(Edit(), "notfocus", "focus").focus_map32{None: 'focus'}33>>> size = (5,)34>>> am = AttrMap(Text("hi"), "greeting", "fgreet")35>>> next(am.render(size, focus=False).content())  # ... = b in Python 336[('greeting', None, ...'hi   ')]37>>> next(am.render(size, focus=True).content())38[('fgreet', None, ...'hi   ')]39>>> am2 = AttrMap(Text(("word", "hi")), {"word": "greeting", None: "bg"})40>>> am241<AttrMap fixed/flow widget <Text fixed/flow widget 'hi'> attr_map={'word': 'greeting', None: 'bg'}>42>>> next(am2.render(size).content())43[('greeting', None, ...'hi'), ('bg', None, ...'   ')]44N)�super�__init__�45isinstancer�dict�attr_map�	focus_map)�self�wrr �	__class__s    �rr�AttrMap.__init__sf���L	������h��(�(� ��N�D�M�!�8�,�D�M��i��)�)�!�)�_�D�N�
�
�&�N�"�I�.�D�Nrc�|>�0[TU]5ESUR0EnURbURUS'U$)Nrr )r�_repr_attrs�	_attr_map�46_focus_map)r!�dr#s  �rr&�AttrMap._repr_attrsMs<���A�u�w�"�$�A�j�$�.�.�A���?�?�&�!�_�_�A�k�N��rc�,�[UR5$�N)rr'�r!s r�get_attr_map�AttrMap.get_attr_mapTs���D�N�N�#�#rc���UR5HBup#[U[5(a[U[5(aM1[U<SU<S35e XlUR5 g)as47Set the attribute mapping dictionary {from_attr: to_attr, ...}48 49Note this function does not accept a single attribute the way the50constructor does.  You must specify {None: attribute} instead.51 52>>> from urwid import Text53>>> w = AttrMap(Text("hi"), None)54>>> w.set_attr_map({"a": "b"})55>>> w56<AttrMap fixed/flow widget <Text fixed/flow widget 'hi'> attr_map={'a': 'b'}>57�:�: attribute mapping is invalid. Attributes must be hashableN)�itemsrrr
r'�_invalidate)r!r�	from_attr�to_attrs    r�set_attr_map�AttrMap.set_attr_mapYsb��#+�.�.�"2��I��i��2�2�*�W�h�:W�:W�"� �m�1�W�K�/i�j���#3�"�����rc�P�UR(a[UR5$gr,)r(rr-s r�
get_focus_map�AttrMap.get_focus_mapqs���?�?�����(�(�rc���UbVUR5HBup#[U[5(a[U[5(aM1[U<SU<S35e XlUR5 g)a=58Set the focus attribute mapping dictionary59{from_attr: to_attr, ...}60 61If None this widget will use the attr mapping instead (no change62when in focus).63 64Note this function does not accept a single attribute the way the65constructor does.  You must specify {None: attribute} instead.66 67>>> from urwid import Text68>>> w = AttrMap(Text("hi"), {})69>>> w.set_focus_map({"a": "b"})70>>> w71<AttrMap fixed/flow widget <Text fixed/flow widget 'hi'> attr_map={} focus_map={'a': 'b'}>72>>> w.set_focus_map(None)73>>> w74<AttrMap fixed/flow widget <Text fixed/flow widget 'hi'> attr_map={}>75Nr1r2)r3rrr
r(r4)r!r r5r6s    r�
set_focus_map�AttrMap.set_focus_mapxsi��(� �&/�o�o�&7�"�	�!�)�X�6�6�j��RZ�>[�>[�&�$�-�q���3m�n���'8�76$�����rc���URnU(aURbURnURRXS9n[	U5nURU5 U$)z;77Render wrapped widget and apply attribute. Return canvas.78)�focus)r'r(�_original_widget�renderr�fill_attr_apply)r!�sizer@r�canvs     rrB�AttrMap.render�sX���>�>���T�_�_�0����H��$�$�+�+�D�+�>���t�$�����X�&��r)r'r(rr r,)r"rr�4Hashable | Mapping[Hashable | None, Hashable] | Noner rG�return�None)rHzdict[str, typing.Any])rHzdict[Hashable | None, Hashable])r�&dict[Hashable | None, Hashable] | NonerHrI)rHrJ)r rJrHrI)F)r@�boolrHr)rrrr�__doc__rr&r.r7�propertyrr:r=r rBr�
__classcell__)r#s@rrrs�����KO�	2/��2/�G�2/�H�	2/�7980�2/�2/�h�$�81�,��l�3�H���:��
�6�I�82�83rrrA)�84__future__r�typing�collections.abcrr�urwid.canvasr�widgetrr	�widget_decorationr85�TypeVarrr
rrrr�<module>rVsN��"�
�-�(�9�/�����/�
�	�;�	�O�&�'9�:�<L�]�<[�Or
codekingpro/portable-devtools · Team Ai