3
8Ad]H  ã               @   s´  d 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mZ ddlm Z m!Z! dd	l"m#Z# dd
l$m%Z% ddl&m'Z' ddl(Z(edd�Z)e
e#dd�Z*edd�Z+edd�Z,edd�Z-ededdddddddddƒ
ddd�Z.ed d�Z/ed!d"d�Z0ed!d#d�Z1eed$d�Z2e	d0d&d�Z3e	d1d'd�Z4e	d2d(d�Z5e	d3d)d�Z6edd*d!d+d�Z7e
d,d-d�Z8G d.d/„ d/eƒZ9dS )4zg Defines the View class used to represent the structural content of a
    Traits-based user interface.
é    )Úabsolute_import)ÚAnyÚBoolÚCallableÚEnumÚEventÚFloatÚInstanceÚListÚStrÚTraitÚTraitPrefixListé   )ÚViewElementÚViewSubElement)ÚUI)
ÚAButtonÚAnObjectÚButtonsÚ	DockStyleÚEditorStyleÚ
ExportTypeÚHelpIdÚImageÚSequenceTypesÚ
ViewStatus)ÚHandlerÚdefault_handler)ÚGroup)ÚItem)ÚIncludeNz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 viewZliveZpanelZsubpanelÚmodalZnonmodalZ	livemodalZpopupZpopoverÚinfoZwizardz!the kind of view window to createé   )r!   Ú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    €„.Az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 windowTzSthe 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/e0Z1e2Z3e4Z5e6Z7eZ8e9Z:e;Z<e=dƒZ>e=dƒZ?e=dƒZ@e=dƒZAe=dƒZBe=dƒZCe=dƒZDdd„ ZEdd„ ZFdd	d
„ZGdd„ ZHdd„ ZIdS )ÚViewal   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|Ž | j|Ž  dS )z! Initializes the object.
        N)r   Ú__init__Úset_content)ÚselfÚvaluesÚtraits© r,   úi/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.6/site-packages/traitsui-6.1.2-py3.6.egg/traitsui/view.pyr'   P  s    zView.__init__c             G   sÖ   g }g }x”|D ]Œ}t |tƒr(|j|ƒ qt|ƒtkrD|jt|Ž ƒ qt |tjƒrŒ|dd… dkrŒ|dd… dkrŒ|jt|dd… j	ƒ ƒƒ q|jt
|ƒƒ qW x"|D ]}t |t
ƒr¤t|Ž g}P q¤W t|d| iŽ| _dS )z% Sets the content of a view.
        Nr   ú<ú>Ú	containeréÿÿÿÿr1   )Ú
isinstancer   ÚappendÚtyper   r   ÚsixÚstring_typesr    Ústripr   Úcontent)r)   r*   r8   ÚaccumÚvalueÚitemr,   r,   r-   r(   Z  s     

 


zView.set_contentNÚ c	          	   C   sâ   |p| j ptƒ }t|tƒs |ƒ }|dk	r4|jf |Ž t|tƒsF|jƒ }|jd|ƒ |d }| jdk	rv| j|d ƒ|d< | j	}	|	dkrž|dkršd|	|f }n|	}|dkr¬| j
}t| |||| j||d�}
|dkrÒ| j}|
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   r2   r   Z	trait_setÚdictZtrait_contextÚ
setdefaultÚ
model_viewrC   rD   r   rB   ÚkindÚui)r)   r@   ÚparentrH   rA   r=   rC   rD   ÚargsZself_idrI   r,   r,   r-   rI   y  s:    #


zView.uic             C   s   | j dk	r| j 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)r8   Úreplace_include)r)   rA   r,   r,   r-   rL   Ë  s    
zView.replace_includec             C   s*   | j dkrdS ddjdd„ | j j D ƒƒ S )z7 Returns a "pretty print" version of the View.
        Nz()z( %s )z, c             S   s   g | ]}|j ƒ ‘qS r,   )Ú__repr__)Ú.0r;   r,   r,   r-   ú
<listcomp>Ý  s    z!View.__repr__.<locals>.<listcomp>)r8   Újoin)r)   r,   r,   r-   rM   ×  s    
zView.__repr__)NNNNr<   NN)JÚ__name__Ú
__module__Ú__qualname__Ú__doc__ÚAnIdrC   ÚContentr8   r   ZmenubarZtoolbarr   Z	statusbarr   Zbuttonsr   Zdefault_buttonÚAKeyBindingsZkey_bindingsÚAHandlerr=   Ú
AModelViewrG   ÚATitlerB   ÚiconÚAKindrH   r   r>   r   Ústyler   Zdockr   ÚimageÚOnApplyZon_applyÚIsResizableZ	resizableÚIsScrollablerD   r   ZexportÚImportTypesZimportsr   Zhelp_idÚXCoordinateÚxÚYCoordinateÚyÚWidthÚwidthÚHeightÚheightZ
drop_classr   ÚupdatedÚCloseResultZclose_resultr   ÚokÚcancelZundoZredoZapplyZrevertÚhelpr'   r(   rI   rL   rM   r,   r,   r,   r-   r&   ™   s\   

   
Or&   g    €„.Ág    €„.Ág    €„.Ág    €„.Á):rT   Ú
__future__r   Z
traits.apir   r   r   r   r   r   r	   r
   r   r   r   Zview_elementr   r   rI   r   Z	ui_traitsr   r   r   r   r   r   r   r   r   r   r=   r   r   Úgroupr   r;   r   Úincluder    r5   rU   rV   rY   rX   rZ   r\   r_   r`   ra   rb   rg   ri   rc   re   rl   rW   r&   r,   r,   r,   r-   Ú<module>   sB   40





