o
    ^i                     @   sz  d 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 ddlmZmZmZ ddlmZ dd	lmZmZmZ G d
d d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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!eG d"d# d#e Z"d$S )%z;String class.

Represents a unicode string using a widget.
   )DescriptionStyleDescriptionWidget)ValueWidget)CallbackDispatcherregisterwidget_serialization)
CoreWidget)ColorInstanceDict
TypedTuple)deprecation    )UnicodeBoolIntc                   @   sb   e Zd ZdZedjddZeddddjddZeddddjddZe	ddd	djddZ
dS )
_StringStyleText input style widget.StringStyleModelTsyncNzBackground specifications.
allow_nonehelpzText font size.z
Text color)__name__
__module____qualname____doc__r   tag_model_name
background	font_sizer	   
text_color r"   r"   [/home/ubuntu/hpml_nyu/venv/lib/python3.10/site-packages/ipywidgets/widgets/widget_string.pyr      s    r   c                   @   s   e Zd ZdZedjddZeddddjddZeddddjddZeddd	djddZ	eddd
djddZ
eddddjddZdS )
LabelStylezLabel style widget.LabelStyleModelTr   NzLabel text font family.r   zLabel text font style.zLabel text font variant.zLabel text font weight.zLabel text decoration.)r   r   r   r   r   r   r   font_family
font_stylefont_variantfont_weighttext_decorationr"   r"   r"   r#   r$      s    r$   c                   @       e Zd ZdZedjddZdS )	TextStyler   TextStyleModelTr   Nr   r   r   r   r   r   r   r"   r"   r"   r#   r,   %       r,   c                   @   r+   )	HTMLStylezHTML style widget.HTMLStyleModelTr   Nr.   r"   r"   r"   r#   r0   *   r/   r0   c                   @   r+   )HTMLMathStylezHTML with math style widget.HTMLMathStyleModelTr   Nr.   r"   r"   r"   r#   r2   /   r/   r2   c                       sp   e Zd ZdZeddjddZedddjddZee	jdddie
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r   Tr   u   ​z7Placeholder text to display when nothing has been typedr   Nc                    s&   |d ur||d< t  jdi | d S )Nvaluer"   )super__init__)selfr6   kwargs	__class__r"   r#   r8   @   s   z_String.__init__StringModelr"   N)r   r   r   r   r   r   r6   placeholderr
   r   r   styler8   r   __classcell__r"   r"   r;   r#   r4   5   s    r4   c                   @   H   e Zd ZdZedjddZedjddZee	jdddie
ZdS )	HTMLz#Renders the string `value` as HTML.HTMLViewTr   	HTMLModelr   Nr"   )r   r   r   r   r   r   
_view_namer   r
   r0   r   r@   r"   r"   r"   r#   rC   G   
    rC   c                   @   rB   )	HTMLMathz;Renders the string `value` as HTML, and render mathematics.HTMLMathViewTr   HTMLMathModelr   Nr"   )r   r   r   r   r   r   rF   r   r
   r2   r   r@   r"   r"   r"   r#   rH   N   rG   rH   c                   @   rB   )	LabelzLabel widget.

    It also renders math inside the string `value` as Latex (requires $ $ or
    $$ $$ and similar latex tags).
    	LabelViewTr   
LabelModelr   Nr"   )r   r   r   r   r   r   rF   r   r
   r$   r   r@   r"   r"   r"   r#   rK   V   s
    rK   c                   @   s   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eejdddieZdS )TextareazMultiline text area widget.TextareaViewTr   TextareaModelNzThe number of rows to display.r   FEnable or disable user changesr5   lUpdate 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   rF   r   r   rowsr   disabledcontinuous_updater
   r,   r   r@   r"   r"   r"   r#   rN   b   s    rN   c                       s   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
eejdd
dieZ fddZdd ZdddZ  ZS )TextSingle line textbox widget.TextViewTr   	TextModelFrQ   r5   rR   r   c                    s*   t  j|i | t | _| | j d S r>   )r7   r8   r   _submission_callbackson_msg_handle_string_msg)r9   argsr:   r;   r"   r#   r8   u   s   zText.__init__c                 C   s"   | dddkr| |  dS dS )zHandle a msg from the front-end.

        Parameters
        ----------
        content: dict
            Content of the msg.
        event submitN)getrZ   )r9   _contentbuffersr"   r"   r#   r\   z   s   zText._handle_string_msgc                 C   s   t d | 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
        zon_submit is deprecated. Instead, set the .continuous_update attribute to False and observe the value changing with: mywidget.observe(callback, 'value').)removeN)r   rZ   register_callback)r9   callbackre   r"   r"   r#   	on_submit   s   zText.on_submitr"   )F)r   r   r   r   r   r   rF   r   r   rT   rU   r
   r,   r   r@   r8   r\   rh   rA   r"   r"   r;   r#   rV   l   s    rV   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 )PasswordrW   PasswordViewTr   PasswordModelFrQ   r5   c                 #   s(    t   }|D ]	}|dkr|V  qd S )Nr6   )r7   
_repr_keys)r9   
super_keyskeyr;   r"   r#   rl      s   
zPassword._repr_keys)r   r   r   r   r   r   rF   r   r   rT   rl   rA   r"   r"   r;   r#   ri      s    ri   c                   @   sZ   e Zd ZdZedjddZedjddZee ddjddZ	e
dd	d
jddZdS )ComboboxzCSingle line textbox widget with a dropdown and autocompletion.
    ComboboxModelTr   ComboboxViewz!Dropdown options for the combobox)traitr   FzDIf set, ensure value is in options. Implies continuous_update=False.r5   N)r   r   r   r   r   r   r   rF   r   optionsr   ensure_optionr"   r"   r"   r#   ro      s     
ro   N)#r   widget_descriptionr   r   valuewidgetr   widgetr   r   r   widget_corer   trait_typesr	   r
   r   utilsr   	traitletsr   r   r   r   r$   r,   r0   r2   r4   rC   rH   rK   rN   rV   ri   ro   r"   r"   r"   r#   <module>   s@   
	(