관리-도구
편집 파일: searchbase.cpython-37.pyc
B � fq � @ s� d Z ddlmZ ddlmZmZmZmZmZm 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 || _ |j| _|| _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_widgets(). title (of dialog): class attribute, override in subclasses. icon (of dialog): ditto, use unclear if cannot minimize dialog. N)�rootZbell�engine�top)�selfr r � r �7/opt/alt/python37/lib64/python3.7/idlelib/searchbase.py�__init__ s zSearchDialogBase.__init__Nc C s� || _ | js| �� n| j�� | j�� | j�|�� � |rZ| j�dd� | j� d|� | j� � | j�dd� | j�d� | j� � dS )z6Make dialog visible on top of others and ready to use.r �endN)�textr �create_widgetsZ deiconifyZtkraise� transientZwinfo_toplevel�ent�delete�insertZ focus_setZselection_rangeZicursorZgrab_set)r r Zsearchphraser r r �open1 s zSearchDialogBase.openc C s* | j r&| j �� | j �d� | j �� dS )zPut dialog away for later use.� N)r Zgrab_releaser Zwithdraw)r Zeventr r r �closeB s zSearchDialogBase.closec C s� t | j�}|�d| j� |�d| j� |�d| j� |�| j� |�| j � || _ d| _| j jdddd� | j jddddd � | � � | �� | �� | �� 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 �rowZgrid_columnconfigure�create_entries�create_option_buttons�create_other_buttons�create_command_buttons)r r r r r r I 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 | � d| jj�d | _dS )z/Create one or more entry lines with make_entry.zFind:r N)r0 r Zpatvarr )r r r r r$ m s zSearchDialogBase.create_entriesc C s\ |r&t | j|d�}|j| jddd� nd}t| j�}|j| jdddd� | jd | _||fS ) z�Return (frame, label). frame - gridded labeled Frame for option or other buttons. label - Label widget, returned for testing. )r r r( )r# r) r* r r r+ )r# r) Z columnspanr* )r r r, r# r )r Z labeltextr. �framer r r � make_frameq s zSearchDialogBase.make_framec C s| | � d�d }| j}|jdf|jdf|jdfg}| jrF|�|jdf� x,|D ]$\}}t|||d�}|j dd d � qLW ||fS )a Return (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. ZOptionsr zRegular expressionz Match casez Whole wordzWrap around)�variabler �left�both)�side�fill) r2 r ZrevarZcasevarZwordvar�needwrapbutton�appendZwrapvarr �pack)r r1 r Zoptionsr- r. �btnr r r r% � s z&SearchDialogBase.create_option_buttonsc C sV | � d�d }| jj}ddg}x.|D ]&\}}t||||d�}|jddd� q$W ||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 Directionr )r ZUp)r ZDown)r3 �valuer r4 r5 )r6 r7 )r2 r Zbackvarr r: )r r1 r- Zothers�valr. r; r r r r&