Current File : //usr/local/apps/python3/lib/python3.11/idlelib/__pycache__/textview.cpython-311.pyc
�

�Ke���H�dZddlmZmZmZmZmZmZmZm	Z	m
Z
mZmZddl
mZmZmZddlmZddlmZGd�de��ZGd�d	e��ZGd
�de��ZGd�d
e��Zdd�Z		dd�Zedkr'ddlmZeddd���ddlmZee��dSdS)zSimple text browser for IDLE

�)�Toplevel�Text�TclError�
HORIZONTAL�VERTICAL�NS�EW�NSEW�NONE�WORD�SUNKEN)�Frame�	Scrollbar�Button)�	showerror)�color_configc�.��eZdZdZ�fd�Zd�Zd�Z�xZS)�AutoHideScrollbarzpA scrollbar that is automatically hidden when not needed.

    Only the grid geometry manager is supported.
    c����t|��dkst|��dkr|���n|���t���||��dS)Ngg�?)�float�grid�grid_remove�super�set)�self�lo�hi�	__class__s   ��:/usr/local/apps/python3/lib/python3.11/idlelib/textview.pyrzAutoHideScrollbar.sets_�����9�9�s�?�?�e�B�i�i�#�o�o��I�I�K�K�K�K�������
�����B�������c�:�t|jj�d����)Nz does not support "pack"�rr�__name__�r�kwargss  r�packzAutoHideScrollbar.packs���$�.�1�K�K�K�L�L�Lr c�:�t|jj�d����)Nz does not support "place"r"r$s  r�placezAutoHideScrollbar.places���$�.�1�L�L�L�M�M�Mr )r#�
__module__�__qualname__�__doc__rr&r(�
__classcell__�rs@rrrsj��������������M�M�M�N�N�N�N�N�N�Nr rc�&��eZdZdZef�fd�	Z�xZS)�ScrollableTextFramezDisplay text with scrollbar(s).c�v��t��j|fi|��t||���x}|_|�ddt
���|�dd���|�dd���t|td|j
���|_|j�ddt���|jj
|d<|tkrUt|td|j���|_|j�ddt$���|jj
|d	<d
Sd
|_d
S)a�Create a frame for Textview.

        master - master widget for this frame
        wrap - type of text wrapping to use ('word', 'char' or 'none')

        All parameters except for 'wrap' are passed to Frame.__init__().

        The Text widget is accessible via the 'text' attribute.

        Note: Changing the wrapping mode of the text widget after
        instantiation is not supported.
        ��wrapr)�row�column�sticky�)�weightF)�orient�	takefocus�command�yscrollcommand�xscrollcommandN)r�__init__r�textrr
�grid_rowconfigure�grid_columnconfigurerr�yview�yscrollrrrr�xview�xscrollr	)r�masterr2r%r>rs     �rr=zScrollableTextFrame.__init__"sJ���	������*�*�6�*�*�*���4�0�0�0�0��t�y��	�	�a��$�	�/�/�/����q���+�+�+��!�!�!�A�!�.�.�.�)��h�38�15��=�=�=���	
����a��"��5�5�5�!%��!1��
���4�<�<�,�T�*�7<�59�Z�A�A�A�D�L�
�L���!�A�b��9�9�9�%)�\�%5�D�!�"�"�"��D�L�L�Lr )r#r)r*r+rr=r,r-s@rr/r/sF�������)�)�$(�# �# �# �# �# �# �# �# �# �# r r/c�,��eZdZdZd�fd�	Zdd�Z�xZS)�	ViewFramez#Display TextFrame and Close button.�wordc�h��t���|��||_|�d|j��|�d|j��t|td���|_|jjx}|_|�	d|��|�
|dd���t|��|���t|d	|jd
���x|_}|j�dd
d���|�d���dS)aCreate a frame for viewing text with a "Close" button.

        parent - parent widget for this frame
        contents - text to display
        wrap - type of text wrapping to use ('word', 'char' or 'none')

        The Text widget is accessible via the 'text' attribute.
        z<Return>z<Escape>i�)�relief�heightz1.0r�disabled)r2�highlightthickness�state�CloseF�r>r:r9�topT�both��side�expand�fill�bottom)rTN)rr=�parent�bind�okr/r
�	textframer>�insert�	configurer�	focus_setr�	button_okr&)rrX�contentsr2r>r_rs      �rr=zViewFrame.__init__Js$���	������ � � �����	�	�*�d�g�&�&�&��	�	�*�d�g�&�&�&�,�T�&��M�M�M����>�.�.��t�y����E�8�$�$�$����D�Q�j��I�I�I��T����������%+��7�D�G�u�&F�&F�&F�	F���������t�&��A�A�A����H��%�%�%�%�%r Nc�8�|j���dS�zDismiss text viewer dialog.N)rX�destroy�r�events  rrZzViewFrame.okds����������r )rH�N)r#r)r*r+r=rZr,r-s@rrGrGHsW�������)�)�&�&�&�&�&�&�4�������r rGc�8��eZdZdZdefddd��fd�Zdd�Z�xZS)	�
ViewWindowz%A simple text viewer dialog for IDLE.TF)�_htest�_utestc���t���|��d|d<|���dz}|���|sdndz}	|�d|�d|	����|�|��t
|||���|_|�d|j	��t|d	|j	d
���x|_}
|j�dd
d���||_
|j
rA|�|��|���|s|���dSdSdS)aShow the given text in a scrollable window with a 'close' button.

        If modal is left True, users cannot interact with other windows
        until the textview window is closed.

        parent - parent of this dialog
        title - string which is title of popup dialog
        contents - text to display in dialog
        wrap - type of text wrapping to use ('word', 'char' or 'none')
        _htest - bool; change box location when running htest.
        _utest - bool; don't wait_window when running unittest.
        ��borderwidth�
�dz	=750x500+�+r1�WM_DELETE_WINDOWrOFrPrQTrRrSN)rr=�winfo_rootx�winfo_rooty�geometry�titlerG�	viewframe�protocolrZrr_r&�is_modal�	transient�grab_set�wait_window)rrXrur`�modalr2rirj�x�yr_rs           �rr=zViewWindow.__init__lsk���	������ � � ���]����� � �2�%����� � �f�$=�B�B�#�>���
�
�)�!�)�)�a�)�)�*�*�*��
�
�5����"�4���=�=�=����
�
�(�$�'�2�2�2�%+�D�w�48�G�u�&N�&N�&N�	N���������t�&��A�A�A���
��=�	#��N�N�6�"�"�"��M�M�O�O�O��
#�� � �"�"�"�"�"�		#�	#�
#�
#r Nc�d�|jr|���|���dSrb)rx�grab_releasercrds  rrZz
ViewWindow.ok�s/���=�	 ��������������r rf)r#r)r*r+rr=rZr,r-s@rrhrhisl�������+�+�6:��!#� ��!#�!#�!#�!#�!#�!#�!#�F�������r rhTrHFc�,�t||||||���S)a�Create text viewer for given text.

    parent - parent of this dialog
    title - string which is the title of popup dialog
    contents - text to display in this dialog
    wrap - type of text wrapping to use ('word', 'char' or 'none')
    modal - controls if users can interact with other windows while this
            dialog is displayed
    _utest - bool; controls wait_window on unittest
    �r2rj)rh)rXrur`r|r2rjs      r�	view_textr��s���f�e�X�u�4��O�O�O�Or c�\�	t|d|���5}|���}ddd��n#1swxYwYt||||||���S#t$rt	dd|�d�|���Yn5t
$r)}	t	d	t
|	��|���Yd}	~	nd}	~	wwxYwdS)
z�Create text viewer for text in filename.

    Return error message if file cannot be read.  Otherwise calls view_text
    with contents of the file.
    �r)�encodingNr�zFile Load ErrorzUnable to load file z .)ru�messagerXzUnicode Decode Error)�open�readr��OSErrorr�UnicodeDecodeError�str)
rXru�filenamer�r|r2rj�filer`�errs
          r�	view_filer��sQ��
(�
�(�C�(�
3�
3�
3�	#�t��y�y�{�{�H�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#����	#�	#�	#�	#�����%�d� &�(�(�(�	(���!�!�!��)�?��?�?�?��	!�	!�	!�	!�	!�	!��!�!�!��.��c�(�(��	!�	!�	!�	!�	!�	!�	!�	!�	!�����!�����4s8�A�5�A�9�A�9�A� B)�7	B)�B$�$B)�__main__)�mainzidlelib.idle_test.test_textview�)�	verbosity�exit)�runN)TrHF) r+�tkinterrrrrrrr	r
rrr
�tkinter.ttkrrr�tkinter.messageboxr�idlelib.colorizerrrr/rGrhr�r�r#�unittestr��idlelib.idle_test.htestr��r r�<module>r�s����;�;�;�;�;�;�;�;�;�;�;�;�;�;�;�;�;�;�;�;�;�;�;�;�;�;�0�0�0�0�0�0�0�0�0�0�(�(�(�(�(�(�*�*�*�*�*�*�N�N�N�N�N�	�N�N�N�&& �& �& �& �& �%�& �& �& �R���������B*�*�*�*�*��*�*�*�ZP�P�P�P�CI������0�z����������D�	*�a�e�D�D�D�D�+�+�+�+�+�+��C�
�O�O�O�O�O��r