3
8Ad]('  ã               @   s    d Z ddlmZ ddlZddljZddlmZ ddl	m
Z
mZmZ ddlmZ ddlmZmZ ed	deƒZd
d„ Zdd„ ZG dd„ dejƒZG dd„ deƒZdS )zÉ Creates a wizard-based wxPython user interface for a specified UI object.

    A wizard is a dialog box that displays a series of pages, which the user
    can navigate with forward and back buttons.
é    )Úabsolute_importNé   )ÚDefaultTitle)Úrestore_windowÚsave_windowÚGroupEditor)Úfill_panel_for_group)ÚTraitÚStrÚ c          
   C   sÊ  | j }|| _i }x2|jƒ D ]&\}}|dk	r8|jƒ ||< qd||< qW || _ | jjƒ  | jj}|dkrht}t	j
|d|ƒ | _}g }g }	| j}
| jjj| ƒ}d }}i }xì|jƒ D ]à}|j|jf||< d	\|_|_t||	ƒ}|j|ƒ t||| ƒ |jƒ }|j|ƒ |jƒ }t||jƒ ƒ}t||jƒ ƒ}|| \|_|_|j�sB|jr®t|d� |_}|j�rz|j|_|	j|ƒ |
j|j|ƒ |jr®| j|j|ƒ q®W |jtj ||ƒƒ t	j!||j"ƒ t#ƒ |d }|j$|ƒ x.|dd… D ]}|j%|ƒ |j&|ƒ |}�qÖW y| j'ƒ  W n,   | jj(ƒ  d| j_)d| _d| _*‚ Y nX | j+j,| jƒ t-| ƒ |j.|d ƒ�r¢| j}x:| j jƒ D ],\}}|dk	�rŒ|| j/|ƒ nd||< �qjW d| _*nd| _*t0| ƒ | j1ƒ  | j| _ i | _dS )
zS Creates a wizard-based wxPython user interface for a specified UI
    object.
    Nr   r   r   )ÚcontrolFTéÿÿÿÿ)r   r   )2ÚcontextÚ_contextÚitemsZclone_traitsÚinfoZbind_contextÚviewÚtitler   ÚwzZWizardr   ÚcontentZ
get_shadowÚget_contentÚidZenabled_whenÚUIWizardPageÚappendr   ZGetSizerZFitZCalcMinÚmaxÚGetWidthÚ	GetHeightÚPageGroupEditorÚeditorÚbindZadd_enabledZSetPageSizeÚwxÚSizeZEVT_WIZARD_PAGE_CHANGINGÚGetIdÚpage_changingZ	FitToPageÚSetPrevÚSetNextZ
prepare_uiZDestroyÚuiÚresultÚhandlerÚpositionr   Z	RunWizardZcopy_traitsr   Úfinish)r&   Úparentr   Znew_contextÚnameÚvaluer   ÚwizardÚpagesZeditor_pagesr   Zshadow_groupZmin_dxZmin_dyZgroup_fields_mappingÚgroupÚpageZsizerÚsizer   Z	prev_pageÚoriginal© r4   úq/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.6/site-packages/traitsui-6.1.2-py3.6.egg/traitsui/wx/ui_wizard.pyÚ	ui_wizard8   sŠ    










r6   c             C   sd   | j ƒ }| jƒ r|jƒ }n|jƒ }|dk	r`|jdk	r`|jj r`| jƒ  |jj}|dkr`tj	|ƒ dS )zD Handles the user attempting to change the current wizard page.
    Nr   )
ZGetPageÚGetDirectionÚGetNextÚGetPrevr   ÚenabledZVetoÚmsgr    Z
MessageBox)Úeventr1   Znew_pager;   r4   r4   r5   r#   ·   s    


r#   c               @   s8   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ ZdS )r   z' A page within a wizard interface.
    c             C   s*   t jj| |ƒ d  | _ | _| _|| _d S )N)r   ÚPyWizardPageÚ__init__ÚnextÚpreviousr   r/   )Úselfr.   r/   r4   r4   r5   r>   Ø   s    zUIWizardPage.__init__c             C   s
   || _ dS )z, Sets the next page after this one.
        N)r?   )rA   r1   r4   r4   r5   r%   á   s    zUIWizardPage.SetNextc             C   s
   || _ dS )z- Sets the previous page to this one.
        N)r@   )rA   r1   r4   r4   r5   r$   ê   s    zUIWizardPage.SetPrevc             C   sN   | j }|dk	rH|jdkrH|j}|dkr*dS x| jD ]}|j|kr2|S q2W | jS )z/ Returns the next page after this one.
        Nr   )r   r?   r/   r   )rA   r   r?   r1   r4   r4   r5   r8   ó   s    
zUIWizardPage.GetNextc             C   sN   | j }|dk	rH|jdkrH|j}|dkr*dS x| jD ]}|j|kr2|S q2W | jS )z0 Returns the previous page to this one.
        Nr   )r   r@   r/   r   )rA   r   r@   r1   r4   r4   r5   r9     s    
zUIWizardPage.GetPrevN)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r>   r%   r$   r8   r9   r4   r4   r4   r5   r   Ñ   s   			r   c               @   s   e Zd ZdZeZeZeZdS )r   z0 Editor for a group, which displays a page.
    N)	rB   rC   rD   rE   Únone_str_traitr?   r@   r
   r;   r4   r4   r4   r5   r     s   r   )rE   Ú
__future__r   r    Z	wx.wizardr.   r   Ú	constantsr   Úhelperr   r   r   Zui_panelr   Z
traits.apir	   r
   ÚstrrF   r6   r#   r=   r   r   r4   r4   r4   r5   Ú<module>   s   
E