3
7ßL]ú  ã               @   s¤   d Z ddlmZ ddlmZm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mZ ddlmZ ddlmZ eeƒG d	d
„ d
eeƒƒZG dd„ dejƒZdS )z( The base class for all pyface wizards. é    )Úprint_function)ÚQtCoreÚQtGui)ÚBoolÚInstanceÚListÚPropertyÚprovidesÚUnicode)ÚDialog)ÚIWizardÚMWizard)ÚIWizardController)ÚIWizardPagec               @   st   e Zd ZdZeeeƒƒZee	ƒ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 )ÚWizardzg The base class for all pyface wizards.

    See the IWizard interface for the API documentation.

    Tc             C   s   d S )N© )Úselfr   r   ú?/tmp/pip-install-5sebvq2j/pyface/pyface/ui/qt4/wizard/wizard.pyÚnext8   s    zWizard.nextc             C   s   d S )Nr   )r   r   r   r   Úprevious;   s    zWizard.previousc             C   s   d S )Nr   )r   Úparentr   r   r   Ú_create_contentsB   s    zWizard._create_contentsc             C   sà   t || ƒ}|jtjjtjjB ƒ |j| jdkƒ |j| j	ƒ | jdkrT|j
j| jƒ | jdkr~tj| jŽ }|j|ƒ |j|ƒ | js’|jtjjƒ | jr´|jtjjƒ |jj| jƒ x| jD ]}| |_|j|ƒ q¼W |jƒ  |S )NÚmodalZnonmodalé   éÿÿÿÿr   )r   r   )Ú_WizardZ
setOptionsr   ÚQWizardZNoDefaultButtonZNoBackButtonOnStartPageZsetModalÚstyleZsetWindowTitleÚtitleÚfinishedÚconnectZ_finished_firedÚsizer   ZQSizeZsetMinimumSizeÚresizeÚshow_cancelZ	setOptionZNoCancelButtonÚhelp_idZHaveHelpButtonZhelpRequestedÚ_help_requestedÚpagesÚpyface_wizardÚaddWizardPageÚsetStartWizardPage)r   r   Úcontrolr!   Úpager   r   r   Ú_create_controlI   s*    





zWizard._create_controlc             C   s   t d| jƒ dS )z+ Called when the 'Help' button is pressed. zShow help forN)Úprintr$   )r   r   r   r   r%   n   s    zWizard._help_requestedc             C   s   | j jS )z The pages getter. )Ú
controllerr&   )r   r   r   r   Ú
_get_pagesv   s    zWizard._get_pagesc             C   sˆ   | j }g }x:|D ]2}y|j|ƒ W q tk
r@   |j|ƒ Y qX qW x|D ]}|jƒ  qLW | jr|x|D ]}| jj|ƒ qhW || j_ dS )z The pages setter. N)r&   ÚremoveÚ
ValueErrorÚappendZdispose_pager*   r(   r.   )r   r&   Z	old_pagesZ	new_pagesr+   r   r   r   Ú
_set_pages{   s    


zWizard._set_pagesc             C   s   ddl m} |ƒ S )z Provide a default controller. r   )ÚWizardController)Zpyface.wizard.wizard_controllerr4   )r   r4   r   r   r   Ú_controller_default•   s    zWizard._controller_defaultN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r&   r   r   r.   r   r#   r
   r   r   r   r   r,   r%   r/   r3   r5   r   r   r   r   r      s   
%r   c               @   s@   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dS )r   z\ A QWizard sub-class that hooks into the controller to determine the
    next page to show. c             C   s4   t jj| |ƒ || _|j| _i | _| jj| j	ƒ dS )z Initialise the object. N)
r   r   Ú__init__Ú_pyface_wizardr.   Ú_controllerÚ_idsZcurrentIdChangedr    Ú_update_controller)r   r   r'   r   r   r   r:   ¡   s
    z_Wizard.__init__c             C   s*   |j | ƒ}| j|_| j|ƒ}|| j|< dS )z' Add a page that provides IWizardPage. N)Zcreate_pager;   r'   ZaddPager=   )r   r+   ZqpageÚidr   r   r   r(   ¬   s    

z_Wizard.addWizardPagec             C   s*   | j jƒ }| j|ƒ}|dkr&| j|ƒ dS )z Set the first page. r   N)r<   Úget_first_pageÚ_page_to_idZ
setStartId)r   r+   r?   r   r   r   r)   µ   s    

z_Wizard.setStartWizardPagec             C   s@   | j ƒ dk r| j| jjƒ ƒS | j| j ƒ  }| jj|ƒ}| j|ƒS )z= Reimplemented to return the id of the next page to display. r   )Z	currentIdrA   r<   r@   r=   Zget_next_page)r   Úcurrentr   r   r   r   ÚnextId¾   s
    z_Wizard.nextIdc             C   s   | j j|ƒ| j_dS )z+ Called when the current page has changed. N)r=   Úgetr<   Zcurrent_page)r   r?   r   r   r   r>   È   s    z_Wizard._update_controllerc             C   s8   |dkrd}n&x$| j jƒ D ]\}}||krP qW d}|S )z" Return the id of the given page. Nr   r   r   )r=   Úitems)r   r+   r?   Úpr   r   r   rA   Î   s    z_Wizard._page_to_idN)
r6   r7   r8   r9   r:   r(   r)   rC   r>   rA   r   r   r   r   r   �   s   		
r   N)r9   Ú
__future__r   Z	pyface.qtr   r   Z
traits.apir   r   r   r   r	   r
   Z
pyface.apir   Zpyface.wizard.i_wizardr   r   Z!pyface.wizard.i_wizard_controllerr   Zpyface.wizard.i_wizard_pager   r   r   r   r   r   r   r   Ú<module>   s    
 