a
    §ˆc(  ã                   @   s\   d Z ddlmZmZ ddlmZ ddlmZ ddl	m
Z
 G dd„ deƒZG d	d
„ d
eƒZdS )zJ Defines the various Boolean editors for the PyQt user interface toolkit.
é    )ÚQtCoreÚQtGuié   )ÚEditor)ÚSimpleEditor)ÚReadonlyColorc                       s8   e Zd ZdZdd„ Z‡ fdd„Zdd„ Zdd	„ Z‡  ZS )
r   zFSimple style of editor for Boolean values, which displays a check box.c                 C   s&   t  ¡ | _| jj | j¡ |  ¡  dS )ú\Finishes initializing the editor by creating the underlying toolkit
        widget.
        N)r   Z	QCheckBoxÚcontrolÚstateChangedÚconnectÚupdate_objectZset_tooltip)ÚselfÚparent© r   ú^/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/traitsui/qt4/boolean_editor.pyÚinit*   s    
zSimpleEditor.initc                    s(   | j d ur| j j | j¡ tƒ  ¡  d S )N)r	   r
   Z
disconnectr   ÚsuperÚdispose©r   ©Ú	__class__r   r   r   2   s    
zSimpleEditor.disposec                 C   s   t |ƒ| _dS )z'Handles the user clicking the checkbox.N)ÚboolÚvalue)r   Ústater   r   r   r   7   s    zSimpleEditor.update_objectc                 C   s0   | j r| j tjjj¡ n| j tjjj¡ dS )ú[Updates the editor when the object trait changes externally to the
        editor.
        N)r   r	   ZsetCheckStater   ZQtZ
CheckStateZCheckedZ	Uncheckedr   r   r   r   Úupdate_editor;   s    zSimpleEditor.update_editor)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   Ú__classcell__r   r   r   r   r   '   s
   r   c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚReadonlyEditorznRead-only style of editor for Boolean values, which displays static text
    of either "True" or "False".
    c                 C   sH   t  ¡ | _| j d¡ t  | j ¡ ¡}| t jjjt	¡ | j 
|¡ dS )r   TN)r   Z	QLineEditr	   ZsetReadOnlyZQPaletteZpaletteZsetColorZ	ColorRoleZBaser   Z
setPalette)r   r   Zpalr   r   r   r   J   s
    
zReadonlyEditor.initc                 C   s$   | j r| j d¡ n| j d¡ dS )r   ÚTrueÚFalseN)r   r	   ZsetTextr   r   r   r   r   [   s    zReadonlyEditor.update_editorN)r   r   r   r   r   r   r   r   r   r   r!   E   s   r!   N)r   Z	pyface.qtr   r   Zeditorr   Ztext_editorr   Z
TextEditorÚ	constantsr   r!   r   r   r   r   Ú<module>   s   