o
    ^il                     @   s   d Z ddl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 ddlmZmZ dd	lmZmZmZmZmZmZ eG d
d dee
ZeG dd dee
ZdS )zButton class.

Represents a button in the frontend using a widget.  Allows user to listen for
click events on the button and trigger backend code when the clicks are fired.
   )deprecation)	DOMWidget)CallbackDispatcherregisterwidget_serialization)
CoreWidget)Style)ColorInstanceDict    )UnicodeBoolCaselessStrEnumInstancevalidatedefaultc                   @   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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 )ButtonStylezButton style widget.ButtonStyleModelTsyncNzColor of the button)
allow_nonehelpzButton text font family.zButton text font size.zButton text font style.zButton text font variant.zButton text font weight.zButton text color.zButton text decoration.)__name__
__module____qualname____doc__r   tag_model_namer	   button_colorfont_family	font_size
font_stylefont_variantfont_weight
text_colortext_decoration r&   r&   [/home/ubuntu/hpml_nyu/venv/lib/python3.10/site-packages/ipywidgets/widgets/widget_button.pyr      s    r   c                       s   e Zd ZdZedjddZedjddZeddjddZe	dd	djddZ
ed
ddjddZeg dd
ddjddZeejdddieZ fddZeddd ZdddZdd Zdd Z  ZS )Buttona  Button widget.

    This widget has an `on_click` method that allows you to listen for the
    user clicking on the button.  The click event itself is stateless.

    Parameters
    ----------
    description: str
       description displayed on the button
    icon: str
       font-awesome icon names, without the 'fa-' prefix
    disabled: bool
       whether user interaction is enabled
    
ButtonViewTr   ButtonModelzButton label.)r   FzEnable or disable user changes. z2Font-awesome icon names, without the 'fa-' prefix.)primarysuccessinfowarningdangerr+   z(Use a predefined styling for the button.)valuesdefault_valuer   r   c                    s*   t  jdi | t | _| | j d S )Nr&   )super__init__r   _click_handlerson_msg_handle_button_msg)selfkwargs	__class__r&   r'   r4   ?   s   zButton.__init__iconc                 C   s0   |d }d|v rt dg dd |dd}|S )zStrip 'fa-' if necessary'valuezfa-z}icons names no longer need 'fa-', just use the class names themselves (for example, 'gear spin' instead of 'fa-gear fa-spin'))zipywidgets/widgets/ztraitlets/traitlets.pyz/contextlib.py)internalr+   )r   replace)r8   proposalr=   r&   r&   r'   _validate_iconD   s   zButton._validate_iconc                 C   s   | j j||d dS )a9  Register a callback to execute when the button is clicked.

        The callback will be called with one argument, the clicked button
        widget instance.

        Parameters
        ----------
        remove: bool (optional)
            Set to true to remove the callback from the list of callbacks.
        )removeN)r5   register_callback)r8   callbackrB   r&   r&   r'   on_clickO   s   zButton.on_clickc                 C   s   |  |  dS )zProgrammatically trigger a click event.

        This will call the callbacks registered to the clicked button
        widget instance.
        N)r5   )r8   r&   r&   r'   click\   s   zButton.clickc                 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.
        eventr+   rF   N)getrF   )r8   _contentbuffersr&   r&   r'   r7   d   s   zButton._handle_button_msgr&   )F)r   r   r   r   r   r   
_view_namer   descriptionr   disabledr<   r   button_styler
   r   r   styler4   r   rA   rE   rF   r7   __classcell__r&   r&   r:   r'   r(   "   s(    


r(   N)r   utilsr   	domwidgetr   widgetr   r   r   widget_corer   widget_styler   trait_typesr	   r
   	traitletsr   r   r   r   r   r   r   r(   r&   r&   r&   r'   <module>   s    