Your IP : 18.119.124.24
3
� f � @ s� d Z ddlmZmZ ddlmZmZmZmZm Z G dd� d�Z
G dd� de
�Zedkr�dd l
mZ ed
ddd
� ddlmZ ee� dS )zBDefine SearchDialogBase used by Search, Replace, and Grep dialogs.� )�Toplevel�Frame)�Entry�Label�Button�Checkbutton�Radiobuttonc @ s| e Zd ZdZdZdZdZdd� Zddd �Zdd
d�Z dd
� Z
dd� Zdd� Zddd�Z
dd� Zdd� Zd dd�Zdd� ZdS )!�SearchDialogBaseay Create 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� c C s || _ || _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)�selfr r � r �7/opt/alt/python36/lib64/python3.6/idlelib/searchbase.py�__init__ s zSearchDialogBase.__init__Nc C s| || _ | js| j� n| jj� | jj� |rJ| 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�ent�delete�insertZ focus_setZselection_rangeZicursorZgrab_set)r r Zsearchphraser r r �open0 s
zSearchDialogBase.openc C s | j r| j j� | j j� dS )zPut dialog away for later use.N)r
Zgrab_releaseZwithdraw)r Zeventr r r �close@ s
zSearchDialogBase.closec C s� t | j�}|jd| j� |jd| j� |jd| j� |j| j� |j| j � || _
|j| _d| _| j
j
dddd� | j
j
ddddd � | j� | j� | j� | j� d
S )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_WINDOWr � )�pad�weightr
�d )r Zminsizer N)r r Zbind�default_commandr ZprotocolZwm_title�titleZwm_iconname�iconr
Zbell�rowZgrid_columnconfigure�create_entries�create_option_buttons�create_other_buttons�create_command_buttons)r r
r r r r F s
zSearchDialogBase.create_widgetsc C sV t | j|d�}|j| jddd� t| j|dd�}|j| jddd� | jd | _||fS )z�Return (entry, label), .
entry - gridded labeled Entry for text entry.
label - Label widget, returned for testing.
)r r �nw)r! �column�sticky)ZtextvariableZexportselectionr
�nwe)r r
�gridr! r )r Z
label_text�var�label�entryr r r �
make_entry^ s zSearchDialogBase.make_entryc C s | j d| jj�d | _dS )z/Create one or more entry lines with make_entry.zFind:r N)r. r Zpatvarr )r r r r r"