a
    §ˆc=  ã                   @   sj   d Z ddl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 e e¡Zee
ƒG dd„ deƒƒZdS )	ú The default perspective. é    N)ÚBoolÚ	HasTraitsÚListÚprovidesÚStrÚTupleé   )ÚIPerspective)ÚPerspectiveItemc                   @   sˆ   e Zd ZdZdZdZeeƒZeeƒZe	e
ƒZedƒZedƒZedƒZdd„ Zdd	„ Zd
d„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )ÚPerspectiver   zpyface.workbench.defaultZDefault©éÿÿÿÿr   Tc                 C   s
   d| j  S )z9 Return an informal string representation of the object. zPerspective(%s))Úid©Úself© r   ú_/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/pyface/workbench/perspective.pyÚ__str__?   s    zPerspective.__str__c                 C   s   | j S )z Trait initializer. )Únamer   r   r   r   Ú_id_defaultJ   s    zPerspective._id_defaultc                 C   sF   | j dkr| j |_ t| jƒdkr0|  || j¡ n
|  |¡ | ¡  dS )a"   Create the perspective in a workbench window.

        For most cases you should just be able to set the 'contents' trait to
        lay out views as required. However, you can override this method if
        you want to have complete control over how the perspective is created.

        r   r   N)Úeditor_area_sizeÚlenÚcontentsÚ_add_contentsÚ_add_allZreset_views©r   Úwindowr   r   r   ÚcreateR   s    


zPerspective.createc                 C   s   dS )zì Called when the perspective is shown in a workbench window.

        The default implementation does nothing, but you can override this
        method if you want to do something whenever the perspective is
        activated.

        Nr   r   r   r   r   Úshowk   s    	zPerspective.showc                 C   s,   |j D ]
}d|_q|D ]}|  ||¡ qdS )z Adds the specified contents. FN)ÚviewsÚvisibleÚ_add_perspective_item)r   r   r   ÚviewÚitemr   r   r   r   z   s    
zPerspective._add_contentsc                 C   sl   t |jƒdkr| |j¡}nd}| |j¡}|durX|j|_| ||j||j|jf¡ nt	 
d|j ¡ dS )z& Adds a perspective item to a window. r   Nz&missing view for perspective item <%s>)r   Úrelative_toÚget_view_by_idr   Z
style_hintÚadd_viewÚpositionÚwidthÚheightÚloggerÚerror)r   r   r$   r%   r#   r   r   r   r"   ˆ   s    ÿz!Perspective._add_perspective_itemc                 C   s"   |j D ]}|jr|  ||¡ qdS )z9 Adds *all* of the window's views defined in the window. N)r    r!   Ú	_add_view)r   r   r#   r   r   r   r   ©   s    
zPerspective._add_allc                 C   s>   t |jƒdkr| |j¡}nd}| ||j||j|jf¡ dS )z Adds a view to a window. r   N)r   r%   r&   r'   r(   r)   r*   )r   r   r#   r%   r   r   r   r-   °   s    ÿzPerspective._add_viewN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Z
DEFAULT_IDZDEFAULT_NAMEr   r   r   r   r   r   r   r   r   ZenabledZshow_editor_arear   r   r   r   r   r"   r   r-   r   r   r   r   r      s"   !r   )r1   ÚloggingZ
traits.apir   r   r   r   r   r   Zi_perspectiver
   Zperspective_itemr   Ú	getLoggerr.   r+   r   r   r   r   r   Ú<module>
   s    
