a
    §ˆcA  ã                   @   sR   d Z ddlmZmZ ddlmZ ddlmZ ddlZe 	e
¡ZG dd„ deƒZdS )	z²
A handler that delegates the handling of events to a set of sub-handlers.

This is typically used as the handler for dynamic views.  See the
**traits.has_dynamic_view** module.
é    )Ú	HasTraitsÚListé   )Ú
Dispatcher)ÚHandlerNc                   @   s6   e Zd ZdZeeƒZeƒ Zdd„ Zdd„ Z	dd„ Z
dS )	ÚDelegatingHandlerzRA handler that delegates the handling of events to a set of
    sub-handlers.
    c                 C   s   | j D ]}| ¡  qdS )z´Handles the user interface being closed by the user.

        This method is overridden here to unregister any dispatchers that
        were set up in the *init()* method.
        N)Ú_dispatchersÚremove)ÚselfÚinfoZis_okÚd© r   ú^/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/traitsui/delegating_handler.pyÚclosed4   s    
zDelegatingHandler.closedc           
   	   C   sú   t  d| ¡ |jj}| jD ]Ú}| |¡ |  |¡D ]À}|dd… dkrØ|dd… }| dd¡}|dkrò| |d|… ¡}|duròt  d||¡ t	||ƒ}||d d… }	| j
 t||||	ƒ¡ | |	¡jd	krò||ƒ q2|d
v r2|  ||¡| j|< q2qdS )a  Initializes the controls of a user interface.

        This method is called after all user interface elements have been
        created, but before the user interface is displayed. Use this method to
        further customize the user interface before it is displayed.

        This method is overridden here to delegate to sub-handlers.

        Parameters
        ----------
        info : *UIInfo* object
            The UIInfo object associated with the view

        Returns
        -------
        initialized : bool
            A boolean, indicating whether the user interface was successfully
            initialized. A True value indicates that the UI can be displayed;
            a False value indicates that the display operation should be
            cancelled.
        z1Initializing delegation in DelegatingHandler [%s]iøÿÿÿNZ_changedÚ_r   r   z	to method [%s] on handler[%s]Úevent)Ztree_item_selectedZinspect_objectT)ÚloggerÚdebugÚuiÚcontextÚsub_handlersÚinitZ_each_trait_methodÚfindÚgetÚgetattrr   Úappendr   Z
base_traitÚtypeÚ_create_delegateÚ__dict__)
r
   r   r   ÚhÚnameÚprefixÚcolÚobjectÚmethodZ
trait_namer   r   r   r   =   s0    

ÿ
ÿ
zDelegatingHandler.initc                    s   ‡ ‡fdd„}|S )z:Quick fix for handler methods that are currently left out!c                     s   t ˆ ˆƒ}|| i |¤ŽS )N)r   )ÚargsÚkwr$   ©r   r    r   r   Údelegate”   s    
z4DelegatingHandler._create_delegate.<locals>.delegater   )r
   r   r    r(   r   r'   r   r   ‘   s    z"DelegatingHandler._create_delegateN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r   r   r   r      s   	Tr   )r,   Z
traits.apir   r   r   r   Úhandlerr   ÚloggingÚ	getLoggerr)   r   r   r   r   r   r   Ú<module>   s   
