3
8ßL]6  ã               @   s`   d Z ddlmZ ddl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 )zM Defines the various button editors for the wxPython user interface toolkit.
é    )Úabsolute_importN)ÚStr)ÚToolkitEditorFactoryé   )ÚEditorc                   sD   e Zd ZdZeZdd„ Zdd„ Zdd„ Zdd	„ Z	‡ fd
d„Z
‡  ZS )ÚSimpleEditorz' Simple style editor for a button.
    c             C   s`   | j jp| jj| jƒ}tj|d| j|ƒƒ| _| j	| j j
ddƒ tj|| jjƒ | jƒ | jƒ  dS )za Finishes initializing the editor by creating the underlying toolkit
            widget.
        r   ÚlabelÚfromNéÿÿÿÿ)Úfactoryr   ÚitemÚ	get_labelÚuiÚwxZButtonÚstring_valueÚcontrolÚ
sync_valueÚlabel_valueÚ
EVT_BUTTONÚGetIdÚupdate_objectÚset_tooltip)ÚselfÚparentr   © r   ú?/tmp/pip-install-5sebvq2j/traitsui/traitsui/wx/button_editor.pyÚinit>   s
    zSimpleEditor.initc             C   s   | j j| j|ƒƒ d S )N)r   ZSetLabelr   )r   r   r   r   r   Ú_label_changedL   s    zSimpleEditor._label_changedc             C   s0   | j }|j| _|jdk	r,| jj|j| jd� dS )zf Handles the user clicking the button by setting the factory value
            on the object.
        N)Úviewr   )r   Úvaluer   ÚobjectZedit_traitsr   )r   Úeventr   r   r   r   r   S   s
    

zSimpleEditor.update_objectc             C   s   dS )z` Updates the editor when the object trait changes externally to the
            editor.
        Nr   )r   r   r   r   Úupdate_editorc   s    zSimpleEditor.update_editorc                s,   t j| jjƒ | jjƒ dƒ tt| ƒjƒ  dS )z0 Disposes of the contents of an editor.
        N)r   r   r   Z	GetParentr   Úsuperr   Údispose)r   )Ú	__class__r   r   r$   m   s    zSimpleEditor.dispose)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r"   r$   Ú__classcell__r   r   )r%   r   r   .   s   
r   c                   s(   e Zd ZdZdd„ Z‡ fdd„Z‡  ZS )ÚCustomEditorzC Custom style editor for a button, which can contain an image.
    c          	   C   s–   ddl m} | j}| jjr$| jj}n| jj| jƒ}||| j|ƒ|j|j	|j
|j|jd�| _| jj| _| jj| jddd� | j| jjddƒ | jƒ  d	S )
za Finishes initializing the editor by creating the underlying toolkit
            widget.
        r   )ÚImageButton)r   ÚimageÚstyleÚorientationÚwidth_paddingÚheight_paddingÚclickedr   )Údispatchr   r	   N)Zpyface.image_buttonr,   r   r   r   r   r   r   r-   r.   r/   r0   r1   Ú_controlr   Úon_trait_changer   r   r   r   )r   r   r,   r   r   r   r   r   r   ‚   s$    

zCustomEditor.initc                s&   | j j| jddd� tt| ƒjƒ  dS )z0 Disposes of the contents of an editor.
        r2   T)ÚremoveN)r4   r5   r   r#   r+   r$   )r   )r%   r   r   r$   ¢   s    zCustomEditor.dispose)r&   r'   r(   r)   r   r$   r*   r   r   )r%   r   r+   y   s    r+   )r)   Ú
__future__r   r   Z
traits.apir   Ztraitsui.editors.button_editorr   Úeditorr   r   r+   r   r   r   r   Ú<module>   s   K