a
    §ˆc
  ã                   @   s˜   d 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. é    )ÚQtCoreÚQtGui)ÚBoolÚInstanceÚListÚPropertyÚprovidesÚStr)Ú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   ú^/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/pyface/ui/qt4/wizard/wizard.pyÚnext:   s    zWizard.nextc                 C   s   d S r   r   r   r   r   r   Úprevious=   s    zWizard.previousc                 C   s   d S r   r   )r   Úparentr   r   r   Ú_create_contentsD   s    zWizard._create_contentsc                 C   sä   t || ƒ}| tjjjtjjjB ¡ | | jdk¡ | 	| j
¡ | jdkrX|j | j¡ | jdkr‚tj| jŽ }| |¡ | |¡ | js˜| tjjj¡ | jr¼| tjjj¡ |j | j¡ | jD ]}| |_| |¡ qÂ| ¡  |S )NÚmodalZnonmodal)éÿÿÿÿr   )Ú_WizardZ
setOptionsr   ÚQWizardZWizardOptionZ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_controlK   s0    
ÿÿ




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%   r   s    zWizard._help_requestedc                 C   s   | j jS )z The pages getter. )Ú
controllerr&   r   r   r   r   Ú
_get_pagesz   s    zWizard._get_pagesc              	   C   sz   | j }g }|D ]0}z| |¡ W q ty<   | |¡ Y q0 q|D ]}| ¡  qD| jrn|D ]}| j |¡ q\|| 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| _i | _| 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|< 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  ¡ }|  |¡}|dkr&|  |¡ 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@   |   ¡ dk r|  | j ¡ ¡S | 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_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   s6   |du rd}n$| j  ¡ D ]\}}||u r q2qd}|S )z" Return the id of the given page. Nr   )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   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     