3
7ßL]D  ã               @   s`   d Z ddlmZ ddlZddlZddlZddlmZm	Z	 ddl
ZddlmZ G dd„ deƒZdS )	z3A dialog that is loaded from an XRC resource file.
é    )Úabsolute_importN)ÚInstanceÚStré   )ÚDialogc               @   sX   e Zd ZdZeZedƒZeej	j
ƒZdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ ZdS )Ú	XrcDialogz7A dialog that is loaded from an XRC resource file.
    Údialogc             C   s<   t jjj| ƒ}tjj|| jƒ}tj	j
|ƒ| _| jj|| jƒS )zL
        Creates the dialog and loads it in from the resource file.
        )ÚtraitsÚutilÚresourceÚget_pathÚosÚpathÚjoinÚxrc_fileÚwxÚxrcÚXmlResourceZ
LoadDialogÚid)ÚselfÚparentZ	classpathr   © r   ú;/tmp/pip-install-5sebvq2j/pyface/pyface/ui/wx/xrc_dialog.pyÚ_create_control8   s    zXrcDialog._create_controlc             C   sœ   | j dƒ}|dk	r4|jtjƒ tj| j|jƒ | jƒ | j dƒ}|dk	rh|jtjƒ tj| j|jƒ | j	ƒ | j dƒ}|dk	r�tj| j|jƒ | j
ƒ | jƒ  dS )z{
        Calls add_handlers.  The actual content is created
        in _create_control by loading a resource file.
        ÚOKNZCANCELZHELP)ÚXRCCTRLZSetIdr   ZID_OKZ
EVT_BUTTONÚcontrolZGetIdZ_on_okZ	ID_CANCELZ
_on_cancelZ_on_helpÚ_add_handlers)r   r   ZokbuttonZcancelbuttonZ
helpbuttonr   r   r   Ú_create_contentsB   s    


zXrcDialog._create_contentsc             C   s   t jj|ƒS )zC
        Returns the numeric widget id for the given name.
        )r   r   ÚXRCID)r   Únamer   r   r   r   ^   s    zXrcDialog.XRCIDc             C   s   | j j| j|ƒƒS )z:
        Returns the control with the given name.
        )r   ZFindWindowByIdr   )r   r    r   r   r   r   d   s    zXrcDialog.XRCCTRLc             C   s   | j |ƒj|ƒ dS )z:
        Sets the validator on the named control.
        N)r   ZSetValidator)r   r    Ú	validatorr   r   r   Úset_validatorj   s    zXrcDialog.set_validatorc             C   s   dS )z1
        Override to add event handlers.
        Nr   )r   r   r   r   r   t   s    zXrcDialog._add_handlersN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r   r   r   r   r"   r   r   r   r   r   r   !   s   	

r   )r&   Ú
__future__r   Úos.pathr   r   Zwx.xrcZ
traits.apir   r   Ztraits.util.resourcer	   r   r   r   r   r   r   r   Ú<module>   s   