3
8ßL]('  ã               @   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ÚmaxZGetWidthZ	GetHeightÚPageGroupEditorÚeditorÚbindZadd_enabledZSetPageSizeÚwxÚSizeZEVT_WIZARD_PAGE_CHANGINGZ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© r1   ú;/tmp/pip-install-5sebvq2j/traitsui/traitsui/wx/ui_wizard.pyÚ	ui_wizard8   sŠ    










r3   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GetPageZGetDirectionÚGetNextÚGetPrevr   ZenabledZVetoÚmsgr   Z
MessageBox)Úeventr.   Znew_pager6   r1   r1   r2   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,   r1   r1   r2   r9   Ø   s    zUIWizardPage.__init__c             C   s
   || _ dS )z, Sets the next page after this one.
        N)r:   )r<   r.   r1   r1   r2   r"   á   s    zUIWizardPage.SetNextc             C   s
   || _ dS )z- Sets the previous page to this one.
        N)r;   )r<   r.   r1   r1   r2   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   )r<   r   r:   r.   r1   r1   r2   r4   ó   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   )r<   r   r;   r.   r1   r1   r2   r5     s    
zUIWizardPage.GetPrevN)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r9   r"   r!   r4   r5   r1   r1   r1   r2   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)	r=   r>   r?   r@   Únone_str_traitr:   r;   r
   r6   r1   r1   r1   r2   r     s   r   )r@   Ú
__future__r   r   Z	wx.wizardr+   r   Ú	constantsr   Úhelperr   r   r   Zui_panelr   Z
traits.apir	   r
   ÚstrrA   r3   r    r8   r   r   r1   r1   r1   r2   Ú<module>   s   
E