a
    ¦ˆc	  ã                   @   sT   d dl mZmZmZ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dS )	é    )ÚAnyÚConstantÚDictÚStrÚType)ÚIFieldé   )ÚAction)ÚActionEventc                   @   sB   e Zd ZdZedƒZeeƒZe	e
eƒZdd„ Zdd„ Zdd„ Zd	S )
ÚFieldActionz¡ A widget action containing an IField

    When the value in the field is changed, the `on_perform` method is called
    with the new value as the argument.
    Zwidgetc                 C   s:   | j f d|i| j¤Ž}| ¡  | | jd¡ ||j_|jS )a�   Called when creating a "widget" style action.

        This constructs an IField-based control directly and binds changes to
        the value to the `value_updated` method.

        Parameters
        ----------
        parent : toolkit control
            The toolkit control, usually a toolbar.

        Returns
        -------
        control : toolkit control
            A toolkit control or None.
        ÚparentÚvalue)Ú
field_typeÚfield_defaultsÚ_createZobserveÚvalue_updatedÚcontrolZ_field)Úselfr   Úfield© r   ú]/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/pyface/action/field_action.pyÚcreate_control"   s
    zFieldAction.create_controlc                 C   s   |j }t|d�}|  |¡ dS )z‡ Handle changes to the field value by calling perform.

        The event passed to `perform` has the `value` as an attribute.
        )r   N)Únewr
   Úperform)r   Úeventr   Úaction_eventr   r   r   r   8   s    
zFieldAction.value_updatedc                 C   s   | j dur|   |j¡ dS )a    Performs the action.

        This dispacthes to the on_perform method with the new value passed
        as an argument.

        Parameters
        ----------
        event : ActionEvent instance
            The event which triggered the action.
        N)Z
on_performr   )r   r   r   r   r   r   A   s    
zFieldAction.performN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ústyler   r   r   r   r   r   r   r   r   r   r   r   r   r   r      s   
	r   N)Z
traits.apir   r   r   r   r   Zpyface.fields.i_fieldr   Úactionr	   r   r
   r   r   r   r   r   Ú<module>   s   