a
    §ˆcs  ã                   @   s(   d dl Z ddlmZ G dd„ deƒZdS )é    Né   )ÚEditorc                       s<   e Zd Zdd„ Z‡ fdd„Zdd„ Zdd„ Zd	d
„ Z‡  ZS )ÚSearchEditorc                 C   s´   d}| j jrtj}tj|d| j|d�| _| j | j j¡ | j 	| j j
¡ | j | j j¡ | j jrr| j tj| j¡ | j jrŒ| j tj| j¡ | j tj| j¡ | j tj| j¡ dS )z\Finishes initializing the editor by creating the underlying toolkit
        widget.
        r   éÿÿÿÿ)ÚvalueÚstyleN)ÚfactoryÚ	enter_setÚwxZTE_PROCESS_ENTERZ
SearchCtrlr   ÚcontrolZSetDescriptiveTextÚtextZShowSearchButtonZsearch_buttonZShowCancelButtonZcancel_buttonÚauto_setZBindÚEVT_TEXTÚupdate_objectÚEVT_TEXT_ENTERÚEVT_SEARCHCTRL_SEARCH_BTNÚEVT_SEARCHCTRL_CANCEL_BTNÚ
clear_text)ÚselfÚparentr   © r   ú\/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/traitsui/wx/search_editor.pyÚinit   s    zSearchEditor.initc                    sx   | j d urj| jjr&| j jtj| jd� | jjrB| j jtj| jd� | j jtj	| jd� | j jtj
| jd� tƒ  ¡  d S )N)Úhandler)r   r   r   ZUnbindr
   r   r   r	   r   r   r   r   ÚsuperÚdispose©r   ©Ú	__class__r   r   r   *   s    
ÿÿÿzSearchEditor.disposec                 C   s4   | j s0| j ¡ | _| jjdkr0t| j| jjdƒ dS )z9Handles the user entering input data in the edit control.Ú TN)Ú
_no_updater   ÚGetValuer   r   Úsearch_event_traitÚsetattrÚobject©r   Úeventr   r   r   r   =   s    zSearchEditor.update_objectc                 C   s:   | j s6| j d¡ d| _| jjdkr6t| j| jjdƒ dS )z3Handles the user pressing the cancel search button.r   TN)r    r   ÚSetValuer   r   r"   r#   r$   r%   r   r   r   r   E   s
    zSearchEditor.clear_textc                 C   s.   | j  ¡ | jkr*d| _| j  | j¡ d| _dS )z[Updates the editor when the object trait changes externally to the
        editor.
        TFN)r   r!   r   r    r'   Z	str_valuer   r   r   r   Úupdate_editorN   s    zSearchEditor.update_editor)	Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r(   Ú__classcell__r   r   r   r   r      s
   	r   )r
   Zeditorr   r   r   r   r   r   Ú<module>   s   