B
    p[h                 @   s   d Z ddlmZ ddlmZ ddlmZmZ ddlm	Z	 ddl
mZmZmZ ddlmZ G d	d
 d
eee	ZeG dd deZeG dd deZeG dd deZeG dd deZeG dd deZeG dd deZdS )z;String class.

Represents a unicode string using a widget.
   )DescriptionWidget)ValueWidget)CallbackDispatcherregister)
CoreWidget    )UnicodeBoolInt)warnc                   sX   e Zd ZdZeddjddZedddjddZd fd	d
	ZedjddZ	  Z
S )_Stringz:Base class used to create widgets that represent a string.zString value)helpT)syncu   ​z7Placeholder text to display when nothing has been typedNc                s&   |d k	r||d< t t| jf | d S )Nvalue)superr   __init__)selfr   kwargs)	__class__ ?lib/python3.7/site-packages/ipywidgets/widgets/widget_string.pyr      s    z_String.__init__ZStringModel)N)__name__
__module____qualname____doc__r   tagr   Zplaceholderr   _model_name__classcell__r   r   )r   r   r      s
   r   c               @   s0   e Zd ZdZedjddZedjddZdS )HTMLz#Renders the string `value` as HTML.ZHTMLViewT)r   Z	HTMLModelN)r   r   r   r   r   r   
_view_namer   r   r   r   r   r   $   s   r   c               @   s0   e Zd ZdZedjddZedjddZdS )HTMLMathz;Renders the string `value` as HTML, and render mathematics.ZHTMLMathViewT)r   ZHTMLMathModelN)r   r   r   r   r   r   r   r   r   r   r   r   r    *   s   r    c               @   s0   e Zd ZdZedjddZedjddZdS )LabelzLabel widget.

    It also renders math inside the string `value` as Latex (requires $ $ or
    $$ $$ and similar latex tags).
    Z	LabelViewT)r   Z
LabelModelN)r   r   r   r   r   r   r   r   r   r   r   r   r!   1   s   r!   c               @   sn   e Zd ZdZedjddZedjddZeddddjddZ	e
d	d
djddZe
dddjddZdS )TextareazMultiline text area widget.ZTextareaViewT)r   ZTextareaModelNzThe number of rows to display.)Z
allow_noner   FzEnable or disable user changes)r   zlUpdate the value as the user types. If False, update on submission, e.g., pressing Enter or navigating away.)r   r   r   r   r   r   r   r   r
   Zrowsr	   disabledcontinuous_updater   r   r   r   r"   <   s   r"   c                   sz   e Zd ZdZedjddZedjddZedddjddZ	edd	djddZ
 fd
dZdd ZdddZ  ZS )TextzSingle line textbox widget.ZTextViewT)r   Z	TextModelFzEnable or disable user changes)r   zlUpdate the value as the user types. If False, update on submission, e.g., pressing Enter or navigating away.c                s*   t t| j|| t | _| | j d S )N)r   r%   r   r   _submission_callbacksZon_msg_handle_string_msg)r   argsr   )r   r   r   r   M   s    zText.__init__c             C   s   | dddkr| |  dS )zHandle a msg from the front-end.

        Parameters
        ----------
        content: dict
            Content of the msg.
        Zevent ZsubmitN)getr&   )r   _ZcontentZbuffersr   r   r   r'   R   s    zText._handle_string_msgc             C   s(   ddl }|dt | jj||d dS )aE  (Un)Register a callback to handle text submission.

        Triggered when the user clicks enter.

        Parameters
        ----------
        callback: callable
            Will be called with exactly one argument: the Widget instance
        remove: bool (optional)
            Whether to unregister the callback
        r   Nzon_submit is deprecated. Instead, set the .continuous_update attribute to False and observe the value changing with: mywidget.observe(callback, 'value').)remove)warningsr   DeprecationWarningr&   Zregister_callback)r   callbackr,   r-   r   r   r   	on_submit]   s    zText.on_submit)F)r   r   r   r   r   r   r   r   r	   r#   r$   r   r'   r0   r   r   r   )r   r   r%   E   s   r%   c                   sT   e Zd ZdZedjddZedjddZedddjddZ	 fd	d
Z
  ZS )PasswordzSingle line textbox widget.ZPasswordViewT)r   ZPasswordModelFzEnable or disable user changes)r   c             #   s.   t t|  }x|D ]}|dkr|V  qW d S )Nr   )r   r1   
_repr_keys)r   Z
super_keyskey)r   r   r   r2   u   s    
zPassword._repr_keys)r   r   r   r   r   r   r   r   r	   r#   r2   r   r   r   )r   r   r1   n   s
   r1   N)r   Zwidget_descriptionr   Zvaluewidgetr   Zwidgetr   r   Zwidget_corer   Z	traitletsr   r	   r
   r-   r   r   r   r    r!   r"   r%   r1   r   r   r   r   <module>   s&   
(