a
    §ˆc³B  ã                   @   sž  d Z ddlmZ ddlmZ ddlmZmZmZm	Z	m
Z
mZmZmZmZmZmZ ddlmZmZ ddlmZ ddlmZmZmZmZmZmZmZmZmZ dd	l m!Z!m"Z" dd
l#m$Z$ ddl%m&Z& ddl'm(Z( edd�Z)ee$dd�Z*edd�Z+edd�Z,edd�Z-eddddd�Z.edd�Z/eddd�Z0eddd�Z1eedd�Z2eddd�Z3eddd�Z4edd d�Z5edd!d�Z6e	d"d#dd$d�Z7ed%d&d�Z8G d'd(„ d(eƒZ9d"S ))zg Defines the View class used to represent the structural content of a
    Traits-based user interface.
é    )ÚImage©ÚActionManagerBuilder)ÚAnyÚBoolÚCallableÚEnumÚEventÚFloatÚInstanceÚListÚ
PrefixListÚStrÚTraité   )ÚViewElementÚViewSubElement)ÚUI)	ÚAButtonÚAnObjectÚButtonsÚ	DockStyleÚEditorStyleÚ
ExportTypeÚHelpIdÚSequenceTypesÚ
ViewStatus)ÚHandlerÚdefault_handler)ÚGroup)ÚItem)ÚIncludezthe name of the view)Údesczthe content of the viewzDthe factory function for converting a model into a model/view objectzthe handler for the viewzthe window title for the view)
ZpanelZsubpanelÚmodalZnonmodalZ	livemodalÚliveZpopupZpopoverÚinfoZwizardr$   z!the kind of view window to createé   )Údefault_valuer"   Úcolsz>the routine to call when modal changes are applied or revertedFz$whether dialog can be resized or notz(whether view should be scrollable or notz<the categories of elements that can be dragged into the viewg    €„.Ázthe width of the view windowzthe height of the view windowz#the x coordinate of the view windowz#the y coordinate of the view windowNTzSthe result to return when the user clicks the window or dialog close button or iconz!traitsui.key_bindings.KeyBindingsz$the global key bindings for the viewc                   @   sú   e Zd ZdZeZeZeZ	eZ
eZeZeZeZeZeZeZeZeZeZeZe Z!e"Z#eZ$e%Z&e'Z(e)Z*e+Z,e-Z.e/Z0e1Z2e3Z4e5Z6e7Z8eƒ Z9e:ƒ Z;e<Z=e>dƒZ?e>dƒZ@e>dƒZAe>dƒZBe>dƒZCe>dƒZDe>dƒZEdd„ ZFdd„ ZGdd	d
„ZHdd„ ZIdd„ ZJdd„ ZKdS )ÚViewa[  A Traits-based user interface for one or more objects.

    The attributes of the View object determine the contents and layout of
    an attribute-editing window. A View object contains a set of Group,
    Item, and Include objects. A View object can be an attribute of an
    object derived from HasTraits, or it can be a standalone object.
    Fc                 O   s    t j| fi |¤Ž | j|Ž  dS )zInitializes the object.N)r   Ú__init__Úset_content)ÚselfÚvaluesZtraits© r.   úP/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/traitsui/view.pyr*   V  s    zView.__init__c                 G   sÎ   g }g }|D ]Š}t |tƒr&| |¡ qt|ƒtv rB| t|Ž ¡ qt |tƒrˆ|dd… dkrˆ|dd… dkrˆ| t|dd…  ¡ ƒ¡ q| t	|ƒ¡ q|D ]}t |t	ƒrœt|Ž g} qºqœt|d| iŽ| _
dS )zSets the content of a view.Nr   ú<éÿÿÿÿú>Ú	container)Ú
isinstancer   ÚappendÚtyper   r   Ústrr!   Ústripr    Úcontent)r,   r-   r9   ÚaccumÚvalueÚitemr.   r.   r/   r+   [  s(    
ÿþý

zView.set_contentNÚ c	              	   C   sæ   |p| j ptƒ }t|tƒs |ƒ }|dur8|jf i |¤Ž t|tƒsJ| ¡ }| d|¡ |d }| jdurz|  |d ¡|d< | j	}	|	dkr¢|dkržd|	|f }n|	}|du r°| j
}t| |||| j||d�}
|du rÖ| j}|
 ||¡ |
S )aÖ  Creates a **UI** object, which generates the actual GUI window or
        panel from a set of view elements.

        Parameters
        ----------
        context : object or dictionary
            A single object or a dictionary of string/object pairs, whose trait
            attributes are to be edited. If not specified, the current object is
            used.
        parent : window component
            The window parent of the View object's window
        kind : string
            The kind of window to create. See the **AKind** trait for details.
            If *kind* is unspecified or None, the **kind** attribute of the
            View object is used.
        view_elements : ViewElements object
            The set of Group, Item, and Include objects contained in the view.
            Do not use this parameter when calling this method directly.
        handler : Handler object
            A handler object used for event handling in the dialog box. If
            None, the default handler for Traits UI is used.
        id : string
            A unique ID for persisting preferences about this user interface,
            such as size and position. If not specified, no user preferences
            are saved.
        scrollable : Boolean
            Indicates whether the dialog box should be scrollable. When set to
            True, scroll bars appear on the dialog box if it is not large enough
            to display all of the items in the view at one time.

        NÚhandlerÚobjectr=   z%s:%s)ÚviewÚcontextr>   Úview_elementsÚtitleÚidÚ
scrollable)r>   r   r4   r   Z	trait_setÚdictZtrait_contextÚ
setdefaultÚ
model_viewrD   rE   r   rC   ÚkindÚui)r,   rA   ÚparentrI   rB   r>   rD   rE   ÚargsÚself_idrJ   r.   r.   r/   rJ   x  s>    *


ù
zView.uic                 C   s   | j dur| j  |¡ dS )z¬Replaces any items that have an ID with an Include object with
        the same ID, and puts the object with the ID into the specified
        ViewElements object.
        N)r9   Úreplace_include)r,   rB   r.   r.   r/   rN   Í  s    
zView.replace_includec                 C   s*   | j du rdS dd dd„ | j j D ƒ¡ S )z-Returns a "pretty print" version of the View.Nz()z( %s )z, c                 S   s   g | ]}|  ¡ ‘qS r.   )Ú__repr__)Ú.0r<   r.   r.   r/   Ú
<listcomp>Ú  ó    z!View.__repr__.<locals>.<listcomp>)r9   Újoin©r,   r.   r.   r/   rO   Õ  s
    
ÿzView.__repr__c                 C   s   t ƒ S )Nr   rT   r.   r.   r/   Ú_action_manager_builder_defaultÝ  s    z$View._action_manager_builder_default)NNNNr=   NN)LÚ__name__Ú
__module__Ú__qualname__Ú__doc__ÚAnIdrD   ÚContentr9   r   ZmenubarZtoolbarZaction_manager_builderr   Z	statusbarr   Zbuttonsr   Zdefault_buttonÚAKeyBindingsZkey_bindingsÚAHandlerr>   Ú
AModelViewrH   ÚATitlerC   r   ZiconÚAKindrI   r   r?   r   Ústyler   ZdockÚimageÚOnApplyZon_applyÚIsResizableZ	resizableÚIsScrollablerE   r   ÚexportÚImportTypesZimportsr   Zhelp_idÚXCoordinateÚxÚYCoordinateÚyÚWidthÚwidthÚHeightÚheightZ
drop_classr	   ÚupdatedÚCloseResultZclose_resultr   ÚokÚcancelZundoZredoÚapplyÚrevertÚhelpr*   r+   rJ   rN   rO   rU   r.   r.   r.   r/   r)   �   sh   
        ÷
Ur)   ):rY   Zpyface.ui_traitsr   Zpyface.action.schema.apir   Z
traits.apir   r   r   r   r	   r
   r   r   r   r   r   Zview_elementr   r   rJ   r   Z	ui_traitsr   r   r   r   r   r   r   r   r   r>   r   r   Úgroupr   r<   r    Úincluder!   rZ   r[   r^   r]   r_   r`   rc   rd   re   rg   rl   rn   rh   rj   rq   r\   r)   r.   r.   r.   r/   Ú<module>   s\   4,
ÿ

ñÿÿü	þ