3
8ßL]Ñ  ã               @   st   d Z ddlmZ ddlmZmZ ddl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.
é    )Úabsolute_import)ÚQtCoreÚQtGui)ÚToolkitEditorFactoryé   )ÚEditor)ÚSimpleEditor)ÚReadonlyColorc               @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	r   zL Simple style of editor for Boolean values, which displays a check box.
    c             C   s&   t jƒ | _| jjj| jƒ | jƒ  dS )za Finishes initializing the editor by creating the underlying toolkit
            widget.
        N)r   Z	QCheckBoxÚcontrolZstateChangedÚconnectÚupdate_objectZset_tooltip)ÚselfÚparent© r   úA/tmp/pip-install-5sebvq2j/traitsui/traitsui/qt4/boolean_editor.pyÚinit6   s    
zSimpleEditor.initc             C   s   t |ƒ| _dS )z1 Handles the user clicking the checkbox.
        N)ÚboolÚvalue)r   Ústater   r   r   r   B   s    zSimpleEditor.update_objectc             C   s,   | j r| jjtjjƒ n| jjtjjƒ dS )z` Updates the editor when the object trait changes externally to the
            editor.
        N)r   r
   ZsetCheckStater   ZQtZCheckedZ	Unchecked)r   r   r   r   Úupdate_editorK   s    zSimpleEditor.update_editorN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   .   s   	r   c               @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚReadonlyEditorzo Read-only style of editor for Boolean values, which displays static text
    of either "True" or "False".
    c             C   sF   t jƒ | _| jjdƒ t j| jjƒ ƒ}|jt jjtƒ | jj	|ƒ dS )za Finishes initializing the editor by creating the underlying toolkit
            widget.
        TN)
r   Z	QLineEditr
   ZsetReadOnlyZQPaletteZpaletteZsetColorZBaser	   Z
setPalette)r   r   Zpalr   r   r   r   b   s
    
zReadonlyEditor.initc             C   s$   | j r| jjdƒ n| jjdƒ dS )z` Updates the editor when the object trait changes externally to the
            editor.
        ÚTrueÚFalseN)r   r
   ZsetText)r   r   r   r   r   s   s    zReadonlyEditor.update_editorN)r   r   r   r   r   r   r   r   r   r   r   Y   s   r   N)r   Ú
__future__r   Z	pyface.qtr   r   Ztraitsui.editors.boolean_editorr   Úeditorr   Ztext_editorr   Z
TextEditorÚ	constantsr	   r   r   r   r   r   Ú<module>   s   +