a
    ¦ˆc$  ã                   @   st   d Z ddlmZ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 edƒZedƒZedƒZG d	d
„ d
eƒZdS )ú: An action manager item that represents an actual action. é    )ÚAnyÚInstanceÚListÚPropertyÚStrÚobserve)ÚAction)ÚActionManagerItem)Útoolkit_objectzaction.action_item:_MenuItemzaction.action_item:_Toolzaction.action_item:_PaletteToolc                   @   s�   e Zd ZdZeeƒZeeƒZ	e
ƒ Ze
ƒ Zee
ƒZdd„ Zedƒdd„ ƒZedƒdd	„ ƒZed
ƒdd„ ƒZdd„ Zddd„Zddd„Zdd„ ZdS )Ú
ActionItemr   c                 C   s   | j jS ©N)ÚactionÚid©Úself© r   ú\/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/pyface/action/action_item.pyÚ_get_id@   s    zActionItem._get_idÚenabledc                 C   s   |j | j_d S r   )Únewr   r   ©r   Úeventr   r   r   Ú_enabled_updatedE   s    zActionItem._enabled_updatedÚvisiblec                 C   s   |j | j_d S r   )r   r   r   r   r   r   r   Ú_visible_updatedI   s    zActionItem._visible_updatedz_wrappers:items:controlc                 C   s   |j du r| j |j¡ dS )z( Handle the destruction of the wrapper. N)r   Ú	_wrappersÚremoveÚobjectr   r   r   r   Ú_on_destroyM   s    
zActionItem._on_destroyc                 C   sJ   |du s|  | j¡rFt||| |ƒ}|du r:|j| _|j| _| j |¡ dS )aD   Add the item to a menu.

        Parameters
        ----------
        parent : toolkit control
            The parent of the new menu item control.
        menu : toolkit menu
            The menu to add the action item to.
        controller : ActionController instance or None
            The controller to use.
        N)Zcan_add_to_menur   Ú	_MenuItemÚcontrolÚ
control_idr   Úappend)r   ÚparentÚmenuÚ
controllerÚwrapperr   r   r   Úadd_to_menuW   s    zActionItem.add_to_menuTc                 C   sN   |du s|  | j¡rJt|||| ||ƒ}|du r>|j| _|j| _| j |¡ dS )aú   Adds the item to a tool bar.

        Parameters
        ----------
        parent : toolkit control
            The parent of the new menu item control.
        tool_bar : toolkit toolbar
            The toolbar to add the action item to.
        image_cache : ImageCache instance
            The image cache for resized images.
        controller : ActionController instance or None
            The controller to use.
        show_labels : bool
            Should the toolbar item show a label.
        N)Zcan_add_to_toolbarr   Ú_Toolr!   r"   r   r#   )r   r$   Ztool_barÚimage_cacher&   Úshow_labelsr'   r   r   r   Úadd_to_toolbarm   s    ÿzActionItem.add_to_toolbarc                 C   s   t ||| |ƒ}| j |¡ dS )a²   Adds the item to a tool palette.

        Parameters
        ----------
        parent : toolkit control
            The parent of the new menu item control.
        tool_palette : toolkit tool palette
            The tool palette to add the action item to.
        image_cache : ImageCache instance
            The image cache for resized images.
        show_labels : bool
            Should the toolbar item show a label.
        N)Ú_PaletteToolr   r#   )r   Ztool_paletter*   r+   r'   r   r   r   Úadd_to_palette‹   s    zActionItem.add_to_palettec                 C   s   | j  ¡  dS )z} Called when the action is no longer required.

        By default this method calls 'destroy' on the action itself.
        N)r   Údestroyr   r   r   r   r/   œ   s    zActionItem.destroyN)T)T)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r	   r   r   r!   r"   r   r   r   r   r   r   r   r(   r,   r.   r/   r   r   r   r   r      s$   


	 ÿ

r   N)r3   Z
traits.apir   r   r   r   r   r   Zpyface.action.actionr	   Z!pyface.action.action_manager_itemr
   Zpyface.toolkitr   r    r)   r-   r   r   r   r   r   Ú<module>   s    