Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/idlelib/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/idlelib/__pycache__/searchbase.cpython-312.opt-1.pyc

�

&Μg����dZddlmZddlmZmZmZmZmZm	Z	ddl
mZGd�d�ZGd�de�Z
ed	k(r dd
lmZeddd
��ddlmZee
�yy)zBDefine SearchDialogBase used by Search, Replace, and Grep dialogs.�)�Toplevel)�Frame�Entry�Label�Button�Checkbutton�Radiobutton)�
_setup_dialogc�f�eZdZdZdZdZdZd�Zdd�Zdd�Z	d	�Z
d
�Zd�Zdd�Z
d
�Zd�Zdd�Zd�Zy)�SearchDialogBaseayCreate most of a 3 or 4 row, 3 column search dialog.

    The left and wide middle column contain:
    1 or 2 labeled text entry lines (make_entry, create_entries);
    a row of standard Checkbuttons (make_frame, create_option_buttons),
    each of which corresponds to a search engine Variable;
    a row of dialog-specific Check/Radiobuttons (create_other_buttons).

    The narrow right column contains command buttons
    (make_button, create_command_buttons).
    These are bound to functions that execute the command.

    Except for command buttons, this base class is not limited to items
    common to all three subclasses.  Rather, it is the Find dialog minus
    the "Find Next" command, its execution function, and the
    default_command attribute needed in create_widgets. The other
    dialogs override attributes and methods, the latter to replace and
    add widgets.
    z
Search Dialog�Search�c�P�||_|j|_||_d|_y)a[Initialize root, engine, and top attributes.

        top (level widget): set in create_widgets() called from open().
        frame: container for all widgets in dialog.
        text (Text searched): set in open(), only used in subclasses().
        ent (ry): created in make_entry() called from create_entry().
        row (of grid): 0 in create_widgets(), +1 in make_entry/frame().
        default_command: set in subclasses, used in create_widgets().

        title (of dialog): class attribute, override in subclasses.
        icon (of dialog): ditto, use unclear if cannot minimize dialog.
        N)�root�bell�engine�top)�selfrrs   �//usr/local/lib/python3.12/idlelib/searchbase.py�__init__zSearchDialogBase.__init__!s$����	��I�I��	�������Nc�P�||_|js|j�n4|jj�|jj	�|jj|j
��|r8|jjdd�|jjd|�|jj�|jjdd�|jjd�|jj�y)z6Make dialog visible on top of others and ready to use.r�endN)�textr�create_widgets�	deiconify�tkraise�	transient�winfo_toplevel�ent�delete�insert�	focus_set�selection_range�icursor�grab_set)rr�searchphrases   r�openzSearchDialogBase.open3s�����	��x�x����!��H�H��� ��H�H���������4�.�.�0�1���H�H�O�O�A�e�$��H�H�O�O�E�,�/���������� � ��E�*�������������rc��|jrP|jj�|jjd�|jj�yy)zPut dialog away for later use.�N)r�grab_releaser�withdraw)r�events  r�closezSearchDialogBase.closeDs@���8�8��H�H�!�!�#��H�H���r�"��H�H����rc��t|j�}|jd|j�|jd|j�|jd|j�|j
|j�|j|j�t|�||_t|d��|_
|jjd��|jdd	�
�|j!dd	�
�d|_|jjddd��|jjd
dd	d	��|j%�|j'�|j)�|j+�y)z�Create basic 3 row x 3 col search (find) dialog.

        Other dialogs override subsidiary create_x methods as needed.
        Replace and Find-in-Files add another entry row.
        z<Return>z<Escape>�WM_DELETE_WINDOW�)�padding�nwes)�stickyr�d)�weight�)�padr6r)r8�minsizer6N)rr�bind�default_commandr.�protocol�wm_title�title�wm_iconname�iconr
rr�frame�grid�grid_columnconfigure�grid_rowconfigure�row�create_entries�create_option_buttons�create_other_buttons�create_command_buttons)rrs  rrzSearchDialogBase.create_widgetsKs+���t�y�y�!������T�1�1�2�����T�Z�Z�(����'����4����T�Z�Z� �����	�	�"��c������3��*��
��
�
���v��&�� � ��3� �/����a���,�����
�
�'�'��q��'�;��
�
�'�'��q�#�c�'�J������"�"�$��!�!�#��#�#�%rc��t|j|��}|j|jdd��t	|j|d��}|j|jdd��|jdz|_||fS)z�Return (entry, label), .

        entry - gridded labeled Entry for text entry.
        label - Label widget, returned for testing.
        �rr�nw�rE�columnr4)�textvariable�exportselectionr�nwe)rrArBrEr)r�
label_text�var�label�entrys     r�
make_entryzSearchDialogBase.make_entrygsk���d�j�j�z�2��
�
�
�t�x�x��$�
�7��d�j�j�s�A�F��
�
�
�t�x�x��%�
�8��8�8�a�<����e�|�rc�`�|jd|jj�d|_y)z/Create one or more entry lines with make_entry.zFind:rN)rVr�patvarr )rs rrFzSearchDialogBase.create_entriests#���?�?�7�D�K�K�,>�,>�?��B��rc��|r6t|j|��}|j|jdd��nd}t	|j�}|j|jddd��|jdz|_||fS)	z�Return (frame, label).

        frame - gridded labeled Frame for option or other buttons.
        label - Label widget, returned for testing.
        rKrrLrMr*rrQ)rErN�
columnspanr4)rrArBrEr)r�	labeltextrTrAs    r�
make_framezSearchDialogBase.make_framexsq����$�*�*�9�5�E��J�J�4�8�8�A�d�J�;��E��d�j�j�!��
�
�
�t�x�x��a��
�F��8�8�a�<����e�|�rc�D�|jd�d}|j}|jdf|jdf|jdfg}|j
r|j
|jdf�|D]&\}}t|||��}|jdd	�
��(||fS)aReturn (filled frame, options) for testing.

        Options is a list of searchengine booleanvar, label pairs.
        A gridded frame from make_frame is filled with a Checkbutton
        for each pair, bound to the var, with the corresponding label.
        �OptionsrzRegular expressionz
Match casez
Whole wordzWrap around)�variabler�left�both��side�fill)
r\r�revar�casevar�wordvar�needwrapbutton�append�wrapvarr�pack)rrAr�optionsrSrT�btns       rrGz&SearchDialogBase.create_option_buttons�s������	�*�1�-�������L�L�"6�7��N�N�L�1��N�N�L�1�3������N�N�F�N�N�M�:�;�!�J�C���e�c��>�C��H�H�&�v�H�.�"��g�~�rc��|jd�d}|jj}ddg}|D]'\}}t||||��}|j	dd���)||fS)	z�Return (frame, others) for testing.

        Others is a list of value, label pairs.
        A gridded frame from make_frame is filled with radio buttons.
        �	Directionr)r�Up)r�Down)r_�valuerr`rarb)r\r�backvarr	rk)rrArS�others�valrTrms       rrHz%SearchDialogBase.create_other_buttons�sj������,�Q�/���k�k�!�!���[�)�� �J�C���e�c��5�I�C��H�H�&�v�H�.�!��f�}�rc���t|j|||xrdxsd��}|jj�\}}|jd|dd��|jj|dz��|S)	z/Return command button gridded in command frame.�active�normal)r�command�defaultrr�ew)�padyrErNr4)�rowspan)r�buttonframe�	grid_sizerB)rrTry�isdef�b�cols�rowss       r�make_buttonzSearchDialogBase.make_button�st���4�#�#��w� �-�X�9��
;���"�"�,�,�.�	��T�	���A�$�a�t��4������d�1�f��-��rc���t|j�x}|_|jdddddd��|j	d|j
�}|j
�y)z9Place buttons in vertical command frame gridded on right.rr7)rErN�padxr|�ipadx�ipady�CloseN)rrAr~rBr�r.�lower)r�fr�s   rrIz'SearchDialogBase.create_command_buttons�sO��$�T�Z�Z�0�0��D��	���1�A�1�!�!�!��<����W�d�j�j�1��	���	r�N)r)�__name__�
__module__�__qualname__�__doc__r>r@rhrr(r.rrVrFr\rGrHr�rI�rrrrsP���(
�E��D��N��$�" �&�8�C�� �&��rrc��eZdZdZd�Zd�Zy)�_searchbasez3Create auto-opening dialog with no text connection.c
�h�ddl}ddlm}||_|j	|�|_|j
�t|j��ttt|jd|j����\}}}}|jjd|dz|dzfz�y)Nr)�searchenginez[x+]z+%d+%d�(�)�re�idlelibr�r�getrr�print�geometry�list�map�int�splitr)r�parentr�r��width�height�x�ys        rrz_searchbase.__init__�s����(���	�"�&�&�v�.�������
�f�o�o�� � ��S�"�(�(�6�6�?�?�;L�*M�!N�O���f�a�������(�a�"�f�a�#�g�%6�6�7rc��yr�r�)r�dummys  rr;z_searchbase.default_command�s��drN)r�r�r�r�rr;r�rrr�r��s��9�	8�+rr��__main__)�mainz!idlelib.idle_test.test_searchbaser7F)�	verbosity�exit)�runN)r��tkinterr�tkinter.ttkrrrrrr	�tkinter.simpledialogr
rr�r��unittestr��idlelib.idle_test.htestr�r�rr�<module>r�sX��H��M�M�.�q�q�h+�"�+�"�z����	,���F�+����r

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists