a
    §ˆc  ã                   @   sX   d Z ddlZddlmZ ddlmZ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.
é    N)ÚImage)ÚStrÚobserveé   )ÚEditorc                       sF   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¡}t |d|  |¡¡| _|  	| j j
dd¡ | j tj| j¡ |  ¡  dS )ú\Finishes initializing the editor by creating the underlying toolkit
        widget.
        éÿÿÿÿÚlabelÚfromN)Úfactoryr
   ÚitemÚ	get_labelÚuiÚwxZButtonÚstring_valueÚcontrolÚ
sync_valueÚlabel_valueZBindÚ
EVT_BUTTONÚupdate_objectÚset_tooltip)ÚselfÚparentr
   © r   ú\/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/traitsui/wx/button_editor.pyÚinit%   s
    zSimpleEditor.initc                 C   s   | j  |  |¡¡ d S ©N)r   ZSetLabelr   ©r   r
   r   r   r   Ú_label_changed/   s    zSimpleEditor._label_changedc                 C   s0   | j }|j| _|jdur,| jj|j| jd� dS )zaHandles 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   2   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_editor=   s    zSimpleEditor.update_editorc                    s   | j  tj¡ tƒ  ¡  dS )ú&Disposes of the contents of an editor.N)r   ZUnbindr   r   ÚsuperÚdisposer$   ©Ú	__class__r   r   r(   C   s    zSimpleEditor.dispose)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r
   r   r   r   r%   r(   Ú__classcell__r   r   r)   r   r      s   
r   c                       sF   e Zd ZdZeƒ Zdd„ Zdd„ Zedƒdd„ ƒZ	‡ fd	d
„Z
‡  ZS )ÚCustomEditorz=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d�| _| jj| _| jj| jddd� |  | jjdd¡ |  | jjd	d¡ |  ¡  d
S )r   r   )ÚImageButton)r
   ÚimageÚstyleÚorientationÚwidth_paddingÚheight_paddingÚclickedr   )Údispatchr
   r   r2   N)Zpyface.ui.wx.image_buttonr1   r   r
   r   r   r   r   r2   r3   r4   r5   r6   Ú_controlr   Úon_trait_changer   r   r   Zimage_valuer   )r   r   r1   r   r
   r   r   r   r   O   s*    
ù	
ÿzCustomEditor.initc                 C   s   |   |¡| j_d S r   )r   r9   r
   r   r   r   r   r   l   s    zCustomEditor._label_changedr2   c                 C   s   |j }|| j_d S r   )Únewr9   r2   )r   r#   r2   r   r   r   Ú_image_updatedo   s    zCustomEditor._image_updatedc                    s"   | j j| jddd� tƒ  ¡  dS )r&   r7   T)ÚremoveN)r9   r:   r   r'   r(   r$   r)   r   r   r(   t   s    ÿzCustomEditor.dispose)r+   r,   r-   r.   r   r2   r   r   r   r<   r(   r/   r   r   r)   r   r0   I   s   
r0   )r.   r   Zpyface.ui_traitsr   Z
traits.apir   r   Zeditorr   r   r0   r   r   r   r   Ú<module>   s   .