a
    ¦ˆcP  ã                   @   sL   d Z ddlmZ ddlmZmZmZmZmZ ddl	m
Z
 G dd„ deƒZdS )z! The base class for all actions. é    ©Úpartial)ÚBoolÚCallableÚEnumÚ	HasTraitsÚStr)ÚImagec                   @   sŒ   e Zd ZdZeƒ ZedƒZeƒ ZedƒZ	edƒZ
eƒ ZeZeƒ ZeZeddddƒZeƒ ZeZdd	„ Zd
d„ Zdd„ Zdd„ Zedd„ ƒZdS )ÚActionaL   The base class for all actions.

    An action is the non-UI side of a command which can be triggered by the end
    user.  Actions are typically associated with buttons, menu items and tool
    bar tools.

    When the user triggers the command via the UI, the action's 'perform'
    method is invoked to do the actual work.

    FTÚpushZradioZtoggleÚwidgetc                 C   s   | j S )zQ Initializes the 'id' trait.

        The default is the ``name`` trait.
        )Úname©Úself© r   úW/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/pyface/action/action.pyÚ_id_defaultP   s    zAction._id_defaultc                 C   s$   | j dkr | jdur |  || ¡S dS )aå   Called when creating a "widget" style action.

        By default this will call whatever callable is supplied via the
        'control_factory' trait which is a callable that should take the parent
        control and the action as arguments and return an appropriate toolkit
        control.  Some operating systems (Mac OS in particular) may limit what
        widgets can be displayed in menus.

        This method is only used when the 'style' is "widget" and is ignored by
        other styles.

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

        Returns
        -------
        control : toolkit control
            A toolkit control or None.
        r   N)ÚstyleÚcontrol_factory)r   Úparentr   r   r   Úcreate_controlY   s    zAction.create_controlc                 C   s   dS )z¬ Called when the action is no longer required.

        By default this method does nothing, but this would be a great place to
        unhook trait listeners etc.
        Nr   r   r   r   r   Údestroys   s    zAction.destroyc                 C   s   | j dur|   ¡  dS )zœ Performs the action.

        Parameters
        ----------
        event : ActionEvent instance
            The event which triggered the action.
        N)Ú
on_perform)r   Úeventr   r   r   Úperformz   s    
zAction.performc                 O   s   t | g|¢R i |¤ŽS )zž Create a factory for an action with the given arguments.

        This is particularly useful for passing context to Tasks schema
        additions.
        r   )ÚclsÚargsÚkwargsr   r   r   Úfactory…   s    zAction.factoryN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Zacceleratorr   ÚcheckedÚdescriptionZenabledZvisibleÚidr	   Úimager   r   r   r   r   Ztooltipr   r   r   r   r   Úclassmethodr   r   r   r   r   r
      s&   	r
   N)r"   Ú	functoolsr   Z
traits.apir   r   r   r   r   Zpyface.ui_traitsr	   r
   r   r   r   r   Ú<module>   s   