a
    ¦ˆc�  ã                   @   sD   d 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 )	z The field interface. é    )ÚAnyÚ	HasTraits)ÚILayoutWidgetc                   @   s   e Zd ZdZeƒ ZdS )ÚIFieldz‚ The field interface.

    A field is a widget that displays a value and (potentially) allows a user
    to interact with it.
    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úvalue© r   r   úX/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/pyface/fields/i_field.pyr      s   r   c                       sp   e Zd ZdZeƒ Z‡ fdd„Z‡ fdd„Z‡ fdd„Zdd	„ Z	d
d„ Z
dd„ Zdd„ Zddd„Zdd„ Z‡  ZS )ÚMFieldz The field mix-in. c                    s    t ƒ  ¡  | j| jddd� dS )z- Set up toolkit-specific bindings for events r
   Úui)ÚdispatchN)ÚsuperÚ_add_event_listenersÚobserveÚ_value_updated©Úself©Ú	__class__r   r   r   (   s    
zMField._add_event_listenersc                    s"   | j | jdddd� tƒ  ¡  dS )z- Remove toolkit-specific bindings for events r
   r   T)r   ÚremoveN)r   r   r   Ú_remove_event_listenersr   r   r   r   r   -   s    
ÿzMField._remove_event_listenersc                    s&   t ƒ  ¡  |  | j¡ |  | j¡ dS )z— Creates the toolkit specific control.

        This method should create the control and assign it to the
        :py:attr:``control`` trait.
        N)r   Ú_createÚshowZvisibleÚenableZenabledr   r   r   r   r   8   s    
zMField._createc                 C   s   |   ¡ | _dS )z‰ Handle a change to the value from user interaction

        This is a method suitable for calling from a toolkit event handler.
        N)Ú_get_control_valuer
   ©r   r
   r   r   r   Ú_update_valueC   s    zMField._update_valuec                 C   s   | j }|du rtdƒ‚|S )z; If control is not passed directly, get it from the trait. NzToolkit control does not exist.)ÚcontrolÚRuntimeError)r   r    r   r   r   Ú_get_controlJ   s    zMField._get_controlc                 C   s
   t ƒ ‚dS )z5 Toolkit specific method to get the control's value. N©ÚNotImplementedErrorr   r   r   r   r   S   s    zMField._get_control_valuec                 C   s
   t ƒ ‚dS )z5 Toolkit specific method to set the control's value. Nr#   r   r   r   r   Ú_set_control_valueW   s    zMField._set_control_valueFc                 C   s
   t ƒ ‚dS )z? Toolkit specific method to change the control value observer. Nr#   )r   r   r   r   r   Ú_observe_control_value[   s    zMField._observe_control_valuec                 C   s   |j }| jd ur|  |¡ d S )N)Únewr    r%   )r   Úeventr
   r   r   r   r   a   s    
zMField._value_updated)F)r   r   r   r	   r   r
   r   r   r   r   r"   r   r%   r&   r   Ú__classcell__r   r   r   r   r      s   	
r   N)r	   Z
traits.apir   r   Zpyface.i_layout_widgetr   r   r   r   r   r   r   Ú<module>   s   