Team Ai
Datasetpublic

codekingpro/portable-devtools

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

2��juH��6�SSKJr SSKrSSKrSSKJr SSKJr SSKJ	r	J3r4Jr SSKJ
r
Jr SSKJr SS	KJrJr SS5KJr SSKJr SSKJrJrJrJr \R:(aSS
KJrJ r J!r! SSK"J#r# "SS\5r$"SS\5r%"SS\\\\
5r&g)�)�annotationsN)�remove_defaults�)�Columns)�Align�Sizing�6WHSettings)� WidgetContainerListContentsMixin�WidgetContainerMixin)�Divider)�MonitoredFocusList�
MonitoredList)�Padding)�Pile)�Widget�WidgetError�
WidgetWarning�7WidgetWrap)�Iterable�Iterator�Sequence)�Literalc��\rSrSrSrSrg)�
GridFlowError�zGridFlow specific error.�N��__name__�8__module__�__qualname__�__firstlineno__�__doc__�__static_attributes__r��\D:\code\apps\devtools\python\user_packages\Python313\site-packages\urwid/widget/grid_flow.pyrrs��"r$rc��\rSrSrSrSrg)�GridFlowWarning�zGridFlow specific warning.rNrrr$r%r'r's��$r$r'c�^�\rSrSrSrS'SjrS(S)U4SjjjrS*U4SjjrS+U4SjjrS,Sjr	S-S	jr9S.U4S10jjrS/Sjr\
S5r\RS0S
j5r\
S-Sj5r\RS1Sj5r\
S2Sj5r\RS5r\R&S4S3SjjrS4Sjr\
S5Sj5rSr\
S5r\RS6Sj5r\
S7Sj5r\RS8Sj5rS9SjrS:SjrS:SjrS.SjrS;U4SjjrS<S=U4SjjjrS>S?U4S jjjr S>S@U4S!jjjr!SAU4S"jjr"SBU4S#jjr#SCU4S$jjr$SDU4S%jjr%S&r&U=r'$)E�GridFlow�z�11The GridFlow widget is a flow widget that renders all the widgets it contains the same width,12and it arranges them from left to right and top to bottom.13c��U(a)[[R[R45$[[R45$)z^Widget sizing.14 15..note:: Empty widget sizing is limited to the FLOW due to no data for width.16)�	frozensetr�FLOW�FIXED��selfs r%�sizing�GridFlow.sizing%s0��17��f�k�k�6�<�<�8�9�9��&�+�+��(�(r$Nc�>^�/nSn[U5HUup�URU18[RU445 US:dM0XjU	1;dUbM<U19R	5(dMSU	nMW [US5n[
XxS9TlTRRTR5 TRRU4Sj5 TRRTR5 UTl
UTlUTlUTlTR#S5Tl[&TT]QTR+TR$455 g)a�20:param cells: iterable of flow widgets to display21:param cell_width: column width for each cell22:param h_sep: blank columns between each cell horizontally23:param v_sep: blank rows between cells vertically24    (if more than one row is required to display all the cells)25:param align: horizontal alignment of cells, one of:26    'left', 'center', 'right', ('relative', percentage 0=left 100=right)27:param focus: widget index or widget instance to focus on28�����rN��focusc�$>�TR5$�N)�_invalidate)�fr1s �r%�<lambda>�#GridFlow.__init__.<locals>.<lambda>Os���D�<L�<L�<Nr$r)�	enumerate�appendr	�GIVEN�29selectable�maxr
�	_contents�set_modified_callbackr:�set_focus_changed_callback�set_validate_contents_modified�_contents_modified�_cell_width�h_sep�v_sep�align�_get_maxcol�
_cache_maxcol�super�__init__�generate_display_widget)r1�cells�30cell_widthrIrJrKr7�prepared_contents�focus_position�idx�widget�	__class__s`          �r%rO�GridFlow.__init__.s���&Y[�� ��$�U�+�K�C��$�$�f�z�/?�/?��.L�%M�N���!�u��
�'=�%�-�TZ�Te�Te�Tg�Tg�!$��,�31�^�Q�/��cu��d32���	
���,�,�T�-=�-=�>����1�1�2N�O����5�5�d�6M�6M�N�%�����33���34���35�!�-�-�b�1���
����5�5�t�7I�7I�6K�L�Mr$c�>�[UR5S:�aS[UR5S3nOUR(aSnOSn/[TU]
5QUP$)Nr�(z items)z(1 item)z())�len�contentsrN�_repr_words)r1�contents_stringrWs  �r%r]�GridFlow._repr_wordsXsU����t�}�}���!� !�#�d�m�m�"4�!5�W�=�O�
�]�]�(�O�"�O�8���$�&�8��8�8r$c�>�0[TU]5EURURURUR36[
UR5S:�aUROSS.En[U[R5$)Nr)rRrIrJrKr7)rN�_repr_attrsrRrIrJrKr[rCrTrr*rO)r1�attrsrWs  �r%ra�GridFlow._repr_attrsask���37��g�!�#�38��/�/��Z�Z��Z�Z��Z�Z�,/����,?�!�,C�T�(�(��
39���u�h�&7�&7�8�8r$c#�# �SURVVs/sHupUPM	 snn4v� SUR4v� SUR4v� SUR4v� SUR4v� SUR404v� gs snnf7f)NrQrRrIrJrKr7)r\rRrIrJrKrT)r1rV�_s   r%�
__rich_repr__�GridFlow.__rich_repr__lsw�����
�
�>�
�9�6��
�>�>�>��D�O�O�+�+��t�z�z�!�!��t�z�z�!�!��t�z�z�!�!��t�*�*�*�*��?�s�A?�A9�AA?c�,�[UR5$r9)r[rCr0s r%�__len__�GridFlow.__len__ts���4�>�>�"�"r$c�0>�SUl[TU]	5 gr9)rMrNr:)r1rWs �r%r:�GridFlow._invalidatews���!���
���r$c���UH.nUunupVU[R:wa[SU<35eM0 g![[4a.n[SU<35RUR5UeSnAff=f)Nzadded content invalid )r	r@r�	TypeError�41ValueError�with_traceback�
__traceback__)r1�_slc�	new_items�item�_w�t�_n�excs        r%rG�GridFlow._contents_modified{s���42�D�
r�"���G�Q��43�(�(�(�'�*@���(I�J�J�)���44�z�*�
r�#�&<�T�H�$E�F�U�U�VY�Vg�Vg�h�nq�q��
r�s�*6�A4�)A/�/A4c�^^�[R"S[SS9 [STR55mUU4SjnTRU5 T$)z�45A list of the widgets in this GridFlow46 47.. note:: only for backwards compatibility. You should use the new48    standard container property :attr:`contents` to modify GridFlow49    contents.50��only for backwards compatibility.You should use the new standard container property `contents` to modify GridFlow.API will be removed in version 5.0.���51stacklevelc3�*# �UH	upUv� M g7fr9r)�.0�wrvs   r%�	<genexpr>�!GridFlow.cells.<locals>.<genexpr>�s���7����1��s�c�>�TTlgr9)rQ)�mlr1s��r%�
user_modified�%GridFlow.cells.<locals>.user_modified�s52����D�Jr$)�warnings�warn�DeprecationWarningrr\rD)r1r�r�s` @r%rQ�GridFlow.cells�sN���	�
�
�
2�
��	53��7����7�
7��	�	� � ��/��	r$c���[R"S[SS9 URnUVs/sH o3[R54UR44PM" snUlU[U5:aX lggs snf)Nr{r|r})	r�r�r�rTr	r@rHr\r[)r1�widgetsrT�news    r%rQr��sq���
�
�
2�
��	55��,�,��PW�X�PW��56� 0� 0�$�2B�2B�C�D�PW�X��
��C��L�(�"0��)��Ys�'A1c��UR$)zO57The width of each cell in the GridFlow. Setting this value affects58all cells.59)rHr0s r%rR�GridFlow.cell_width�s�����r$c��URnURVVs/sHup4U[RU44PM snnUlX lXlgs snnfr9)rTr\r	r@rH)r1�widthrTr��optionss     r%rRr��sK���,�,��LP�M�M�Z�M�L�Q�!�j�.�.��6�7�M�Z��
�,�� ���[s� Ac��UR$)a�60The contents of this GridFlow as a list of (widget, options)61tuples.62 63options is currently a tuple in the form `('fixed', number)`.64number is the number of screen columns to allocate to this cell.65'fixed' is the only type accepted at this time.66 67This list may be modified like a normal list and the GridFlow68widget will update automatically.69 70.. seealso:: Create new options tuples with the :meth:`options` method.71�rCr0s r%r\�GridFlow.contents�s���~�~�r$c� �XRSS&gr9r�)r1�cs  r%r\r��s�����q�r$c��U[R:wa[SU<35eUcURn[U5U4$)z�72Return a new options tuple for use in a GridFlow's .contents list.73 74width_type -- 'given' is the only value accepted75width_amount -- None to use the default cell_width for this GridFlow76zinvalid width_type: )r	r@rrH)r1�77width_type�width_amounts   r%r��GridFlow.options�sF����)�)�)��"6�z�n� E�F�F����+�+�L��:�&��5�5r$c���[R"S[SS9 [U[5(a@US:dU[UR5:�a[SU35eXRlg[UR5HunupEX:XdMX0l
 g [SU<35e![a-n[SU35RUR5UeSnAff=f)a78Set the cell in focus, for backwards compatibility.79 80.. note:: only for backwards compatibility. You may also use the new81    standard container property :attr:`focus_position` to get the focus.82 83:param cell: contained element to focus84:type cell: Widget or int85z�only for backwards compatibility.You may also use the new standard container property `focus_position` to set the focus.API will be removed in version 5.0.r|r}r�%No GridFlow child widget at position N�'Widget not found in GridFlow contents: )r�r�r��86isinstance�intr[r\�87IndexErrorrnrprqr7r>rTro)r1�cellrx�ir��_optionss      r%�	set_focus�GridFlow.set_focus�s���	�
�
�
2�
��	88��d�C� � �
��!�8�t�s�4�=�=�'9�9�$�'L�T�F�%S�T�T� :�#'�M�M��� )�$�-�-� 8��A�}���y�&'�#��!9��B�4�(�K�L�L���
� �#H���!O�P�_�_��%�%�����
�s�-B-�-89C$�7(C�C$c�^�UR(dgURURS$)z8the child widget in focus or None when GridFlow is emptyNr)r\rTr0s r%r7�GridFlow.focuss(���}�}���}�}�T�0�0�1�!�4�4r$c��[R"S[SS9 UR(dgURURS$)z�90Return the widget in focus, for backwards compatibility.91 92.. note:: only for backwards compatibility. You may also use the new93    standard container property :attr:`focus` to get the focus.94z�only for backwards compatibility.You may also use the new standard container property `focus` to get the focus.API will be removed in version 5.0.r|r}Nr)r�r�r�r\rTr0s r%�	get_focus�GridFlow.get_focussC��	�
�
�
2�
��	95��}�}���}�}�T�0�0�1�!�4�4r$c�N�[R"S[SS9 UR$)N��only for backwards compatibility.You may also use the new standard container property`focus` to get the focus and `focus_position` to get/set the cell in focus by index.API will be removed in version 5.0.r|r})r�r�r�r7r0s r%�96focus_cell�GridFlow.focus_cells'���
�
�
2�
��
	97��z�z�r$c��[R"S[SS9 [UR5Hunup4X:XdMX l g [
SU<35e)Nr�r|r}r�)r�r�r�r>r\rTro)r1r�r�r�r�s     r%r�r�*sZ���
�
�
2�
��
	98�!*�$�-�-� 8��A�}���y�&'�#��!9��B�4�(�K�L�Lr$c�f�UR(d[S5eURR$)z{99index of child widget in focus.100Raises :exc:`IndexError` if read when GridFlow is empty, or when set to an invalid index.101z$No focus_position, GridFlow is empty)r\r�r7r0s r%rT�GridFlow.focus_position:s'���}�}��C�D�D��}�}�"�"�"r$c���US:dU[UR5:�a[SU35eXRlg![a-n[SU35R	UR1025UeSnAff=f)zN103Set the widget in focus.104 105position -- index of child widget to be made focus106rr�N)r[r\r�rnrprqr7)r1�positionrxs   r%rTr�Ds���	��!�|�x�3�t�}�}�+=�=� �#H��107�!S�T�T� >�'�
�
���	�	��D�X�J�O�P�_�_��!�!���
��	�s�-A�108A8�(A3�3A8c�$�U(aIUunU(a<X R:a-[R"SU<SUR<S3[SS9 U$U(a6[	U5UR-[	U5S-109UR110--nU$SnU$)Nz!Size is smaller than cell width (z < �)�r}rr)rRr�r�r'r[rI�r1�size�maxcols   r%rL�GridFlow._get_maxcolTs�����I�V�����0��
�
�7��z��T�_�_�DW�WX�Y�#� ���
�	���Y����0�C��I��M�T�Z�Z�3O�O�F��
��F��
r$c��URU5nURU:XaUR$X lURU45UlUR$)z~111Arrange the cells into columns (and possibly a pile) for112display, input or to calculate rows, and update the display113widget.114)rLrMrurPr�s   r%�get_display_widget�GridFlow.get_display_widgetcsP���!�!�$�'������'��7�7�N�#���.�.��y�9����w�w�r$c���URU5n[5nUR(dU$URS:�aURS-115UlSn[/5nSn[
UR5GH�ununup�UbX&-116U117:a�UR(a*URRX5R545 [/UR5nSn[X@R5nX|l
URRX�R545 URRX�R[R[!X�5545 XpR":XdW(d4UR%5(a['UR5S-118UlSnXpR":Xa['UR5S-119Ul[)SUR55UR['UR5--nX`R-120WlGM� UR(aURSS2	U$UR-5 U$)z3121Actually generate display widget (ignoring cache)122rNrFTc3�0# �UHoSSv� M g7f)rNr)r��xs  r%r��3GridFlow.generate_display_widget.<locals>.<genexpr>�s���9�j��q�T�!�W�j�s�)rLrr\rJ�toprr>r?r�rrIrrK�first_positionr	r@�minrTrAr[�sumr�rG)
r1r�r��dividerr��p�123used_spacer�r��_width_typer��column_focused�pads
             r%rP� GridFlow.generate_display_widgetts����!�!�$�'���)���}�}��N��:�:��>��*�*�q�.�G�K�����H���124�3<�T�]�]�3K�/�A�/��.�K��y�F�/�,�>��:�:��J�J�%�%�w�	�	��&<�=��B��125�126�+��!&���a���,��%&�"��127�128�!�!�3�	�	��"4�5�
�J�J���q�)�)�J�,<�,<�c�,�>W�"X�Y�Z��(�(�(�.�Q�\�\�^�^�#&�q�z�z�?�Q�#6�� �!%���'�'�'�#&�q�z�z�?�Q�#6�� ��9�a�j�j�9�9�D�J�J��Q�Z�Z��<X�X�J�"�Z�Z�/�C�I�+4L�.�:�:��129�130�2�A�2��131��
� � �"��r$c���URRnU(dgURnUR(a
URnOSnURU-Ulg)z;132Set the focus to the item in focus in the display widget.133Nr)rur7�base_widgetrTr�)r1�134pile_focusr��col_focus_positions    r%�_set_focus_from_display_widget�'GridFlow._set_focus_from_display_widget�sO���W�W�]�]�135����"�"���7�7�!"�!1�!1��!"��(�7�7�:L�L��r$c�p>�URU5 [TU]	X5=nbU$UR5 g)zG136Pass keypress to display widget for handling.137Captures focus changes.138N)r�rN�keypressr�)r1r��keyrWs   �r%r��GridFlow.keypress�s<���	
����%��7�#�D�.�.�C�;��J��+�+�-�r$c��>�U(a[TU]X5$U(a5[U5UR-[U5S-139UR--nOSnX0RU4U54$)Nrr)rN�packr[rRrI�rows)r1r�r7�colsrWs    �r%r��
GridFlow.pack�s]���140��7�<��,�,���t�9�t���.�#�d�)�a�-�4�:�:�1M�M�D��D��Y�Y��w��.�.�.r$c�@>�URU5 [TU]	XS9$)Nr6)r�rNr��r1r�r7rWs   �r%r��
GridFlow.rows�s"�������%��w�|�D�|�.�.r$c�D>�URU5 [TU]	X5$r9)r�rN�renderr�s   �r%r��GridFlow.render�s"���141	
����%��w�~�d�*�*r$c�D>�URU5 [TU]	U5$)zGet cursor from display widget.)r�rN�get_cursor_coords�r1r�rWs  �r%r��GridFlow.get_cursor_coords�s!�������%��w�(��.�.r$c�j>�URU5 [TU]	XU5nUR5 U$)z/Set the widget in focus based on the col + row.)r�rN�move_cursor_to_coordsr�)r1r��col�row�rvalrWs     �r%r��GridFlow.move_cursor_to_coords�s3�������%��w�,�T��<���+�+�-��r$c�j>�URU5 [TU]	XX4XV5 UR5 g)NT)r�rN�mouse_eventr�)r1r��event�buttonr�r�r7rWs       �r%r��GridFlow.mouse_event�s3���	
����%�
���D��c�A��+�+�-�r$c�D>�URU5 [TU]	U5$)z$Return pref col from display widget.)r�rN�get_pref_colr�s  �r%r��GridFlow.get_pref_cols!�������%��w�#�D�)�)r$)142rMrHrCrurKrQr\rTrIrJ)�returnzfrozenset[Sizing]r9)rQzIterable[Widget]rRr�rIr�rJr�rKzaLiteral['left', 'center', 'right'] | Align | tuple[Literal['relative', WHSettings.RELATIVE], int]r7zint | Widget | Noner��None)r�z	list[str])r�zdict[str, typing.Any])r�z4Iterator[tuple[str | None, typing.Any] | typing.Any])r�r�)r�r�)rrztuple[int, int, int]rszGIterable[tuple[Widget, tuple[Literal['given', WHSettings.GIVEN], int]]]r�r�)r�zSequence[Widget])r�r�r�r�)r�zHMonitoredFocusList[tuple[Widget, tuple[Literal[WHSettings.GIVEN], int]]])r�z"Literal['given', WHSettings.GIVEN]r��143int | Noner�z%tuple[Literal[WHSettings.GIVEN], int])r�zWidget | intr�r�)r�z
Widget | None)r�rr�r�)r�r�)r�r�r�r�)r��tuple[int] | tuple[()]r�r�)r�r�r�zDivider | Pile)r�r�r��strr�z144str | None)rF)r�r�r7�boolr��tuple[int, int])F)r�z145tuple[int]r7r�r�r�)r�r�r7r�)r�r�r�r�)r�r�r�r�r�r�)r�r�r�r�r�r�r�r�r�r�r7r�r�z
Literal[True])r�r�)(rrr r!r"r2rOr]rarfrir:rG�propertyrQ�setterrRr\r	r@r�r�r7r�r�rTrLr�rPr�r�r�r�r�r�r�r�r�r#�
__classcell__)rWs@r%r*r*s�����146)� &*�(N��(N��(N��	(N�147�(N�q�
(N�#�(N�148�(N�(N�T9�	9�+�#��r�"�r�[�r�149�	r�����.�\�\�1��1�� �� ����!��!����� �_�_����150:D�9I�9I�#'�6�6�6�!�6�151/�	6�" M�D�5��5�5�$�	��	����
M��
M��#��#����
'��
'�
��"0�dM�0�$����152�	�&(*��/�$�/��/�153�	/�/�/�/��+�$�+��+�+�/�154��$�����	�155���
���156��*�*r$r*)'�157__future__r�typingr��urwid.split_reprr�columnsr�	constantsrrr	�	containerr158rr�r�monitored_listr
r�paddingr�pilerrVrrrr�
TYPE_CHECKING�collections.abcrrr�typing_extensionsrrr'r*rr$r%�<module>rsr��"�
��,��0�0�M��=���B�B�	���<�<�)�#�K�#�%�m�%�f*�z�$��!5�7W�f*r$
codekingpro/portable-devtools · Team Ai