3
8ßL]  ã               @   sX   d Z ddlmZ ddlZddlmZmZmZ ddlm	Z	 ddl
mZ G dd	„ d	eƒZdS )
z• Defines the HTML "editor" for the QT4 user interface toolkit.
    HTML editors interpret and display HTML-formatted text, but do not
    modify it.
é    )Úabsolute_importN)ÚQtCoreÚQtGuiÚQtWebKit)ÚStré   )ÚEditorc               @   s8   e Zd ZdZdZeZdd„ Zdd„ Zdd„ Z	d	d
„ Z
dS )ÚSimpleEditorz# Simple style editor for HTML.
    Tc             C   sn   t jƒ | _| jjtjjtjjƒ | jjrN| jj	ƒ }|j
t jjƒ |jj| jƒ | jj| _| j| jjddƒ dS )za Finishes initializing the editor by creating the underlying toolkit
            widget.
        Úbase_urlÚfromN)r   ZQWebViewÚcontrolZsetSizePolicyr   ZQSizePolicyZ	ExpandingÚfactoryZopen_externallyÚpageZsetLinkDelegationPolicyZQWebPageZDelegateAllLinksZlinkClickedÚconnectÚ_link_clickedr
   Z
sync_valueZbase_url_name)ÚselfÚparentr   © r   ú>/tmp/pip-install-5sebvq2j/traitsui/traitsui/qt4/html_editor.pyÚinit9   s    



zSimpleEditor.initc             C   s`   | j }| jjr| jj|ƒ}| jrP| j}|jdƒs8|d7 }| jj|tj	j
|ƒƒ n| jj|ƒ dS )z^ Updates the editor when the object trait changes external to the
            editor.
        ú/N)Z	str_valuer   Zformat_textZ
parse_textr
   Úendswithr   ZsetHtmlr   ZQUrlZfromLocalFile)r   ÚtextÚurlr   r   r   Úupdate_editorM   s    
zSimpleEditor.update_editorc             C   s   | j ƒ  d S )N)r   )r   r   r   r   Ú_base_url_changed^   s    zSimpleEditor._base_url_changedc             C   s   t j|jƒ ƒ d S )N)Ú
webbrowserZopen_newÚtoString)r   r   r   r   r   r   a   s    zSimpleEditor._link_clickedN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Z
scrollabler   r
   r   r   r   r   r   r   r   r   r	   &   s   r	   )r!   Ú
__future__r   r   Z	pyface.qtr   r   r   Z
traits.apir   Úeditorr   r	   r   r   r   r   Ú<module>   s   