Your IP : 18.216.167.229


Current Path : /opt/alt/python35/lib64/python3.5/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/idlelib/__pycache__/SearchDialogBase.cpython-35.pyc



��Yfa�@s|dZddlmZmZmZmZmZmZmZGdd�d�Z	e
dkrxddlZejddd	�dS)
zBDefine SearchDialogBase used by Search, Replace, and Grep dialogs.�)�Toplevel�Frame�Entry�Label�Button�Checkbutton�Radiobuttonc@s�eZdZdZdZdZdZdd�Zddd	�Zdd
d�Z	dd
�Z
dd�Zdd�Zddd�Z
dd�Zdd�Zddd�Zdd�ZdS)�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 DialogZSearch�cCs||_||_d|_dS)a'Initialize root, engine, and top attributes.

        top (level widget): set in create_widgets() called from open().
        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_widgers().

        title (of dialog): class attribute, override in subclasses.
        icon (of dialog): ditto, use unclear if cannot minimize dialog.
        N)�root�engine�top)�selfrr�r�=/opt/alt/python35/lib64/python3.5/idlelib/SearchDialogBase.py�__init__s		zSearchDialogBase.__init__NcCs�||_|js|j�n|jj�|jj�|re|jjdd�|jjd|�|jj�|jj	dd�|jj
d�|jj�dS)z6Make dialog visible on top of others and ready to use.r�endN)�textr
�create_widgetsZ	deiconifyZtkraise�entZdelete�insertZ	focus_setZselection_rangeZicursorZgrab_set)rrZsearchphraserrr�open/s		



zSearchDialogBase.opencCs'|jr#|jj�|jj�dS)zPut dialog away for later use.N)r
Zgrab_releaseZwithdraw)rZeventrrr�close?s	
zSearchDialogBase.closecCs�t|j�}|jd|j�|jd|j�|jd|j�|j|j�|j|j	�||_
d|_|j
jddddd�|j
jdddd	d
dd
�|j
�|j�|j�|j�dS)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>ZWM_DELETE_WINDOWrZpad�Zweightr
Zminsize�dN)rrZbindZdefault_commandrZprotocolZwm_title�titleZwm_iconname�iconr
�rowZgrid_columnconfigure�create_entries�create_option_buttons�create_other_buttons�create_command_buttons)rr
rrrrEs		"


zSearchDialogBase.create_widgetscCs�t|jd|�}|jd|jdddd�t|jd|dd�}|jd|jdd	dd
�|jd	|_||fS)z�Return (entry, label), .

        entry - gridded labeled Entry for text entry.
        label - Label widget, returned for testing.
        rr�columnr�sticky�nwZtextvariableZexportselectionr
�nwe)rr
�gridrr)rZ
label_text�var�label�entryrrr�
make_entry\szSearchDialogBase.make_entrycCs#|jd|jj�d|_dS)z/Create one or more entry lines with make_entry.zFind:rN)r*rZpatvarr)rrrrriszSearchDialogBase.create_entriesc	Cs�|r=t|jd|�}|jd|jdddd�nd}t|j�}|jd|jddd	ddd
�|jd|_||fS)z�Return (frame, label).

        frame - gridded labeled Frame for option or other buttons.
        label - Label widget, returned for testing.
        rrr"rr#r$�r
Z
columnspanr%)rr
r&rr)rZ	labeltextr(�framerrr�
make_framems"%zSearchDialogBase.make_framec	Cs�|jd�d}|j}|jdf|jdf|jdfg}|jre|j|jdf�x^|D]V\}}t|ddd	|d
|�}|j	ddd
d�|j
�rl|j�qlW||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.
        ZOptionsrzRegular expressionz
Match casez
Whole wordzWrap around�anchor�w�variabler�side�left�fill�both)r-rZrevarZcasevarZwordvar�needwrapbutton�appendZwrapvarr�pack�get�select)rr,rZoptionsr'r(�btnrrrr}s		z&SearchDialogBase.create_option_buttonscCs�|jd�d}|jj}ddg}xj|D]b\}}t|ddd|d	|d
|�}|jddd
d�|j�|kr2|j�q2W||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.
        Z	Directionrr
�Up�Downr.r/r0�valuerr1r2r3r4)r
r;)rr<)r-rZbackvarrr7r8r9)rr,r'Zothers�valr(r:rrrr �sz%SearchDialogBase.create_other_buttonsrc	Cst|jd|d|d|r$dp'd�}|jj�\}}|jddd|d	d
dd�|jjd
|d�|S)z/Return command button gridded in command frame.r�command�defaultZactiveZnormal�padyr
rr"rr#ZewZrowspan)r�buttonframeZ	grid_sizer&)rr(r?Zisdef�bZcolsZrowsrrr�make_button�s"zSearchDialogBase.make_buttonc
Csgt|j�}|_|jdddddddddddd�|jd	|j�}|j�d
S)z9Place buttons in vertical command frame gridded on right.rrr"rZpadxrAZipadxZipadyrN)rr
rBr&rDr�lower)r�frCrrrr!�s.z'SearchDialogBase.create_command_buttons)�__name__�
__module__�__qualname__�__doc__rrr5rrrrr*rr-rr rDr!rrrrr	s

r	�__main__Nz'idlelib.idle_test.test_searchdialogbase�	verbosityr)
rJZtkinterrrrrrrrr	rGZunittest�mainrrrr�<module>s4�

?>