B
    p[2                 @   s   d 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 dd	l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.
   )	DOMWidget)CallbackDispatcherregisterwidget_serialization)
CoreWidget)Style)ColorInstanceDict    )UnicodeBoolCaselessStrEnumInstancevalidatedefaultNc               @   sH   e Zd ZdZedjddZeddddjddZedd	jddZ	dS )
ButtonStylezButton style widget.ZButtonStyleModelT)syncNzColor of the button)Z
allow_nonehelpzButton text font weight.)r   )
__name__
__module____qualname____doc__r   tag_model_namer   Zbutton_colorZfont_weight r   r   ?lib/python3.7/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jddZ	e
d	d
djddZedddjddZeddddddgdddjddZeejf 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 next to the button
    tooltip: str
       tooltip caption of the toggle button
    icon: str
       font-awesome icon name
    disabled: bool
       whether user interaction is enabled
    Z
ButtonViewT)r   ZButtonModelzButton label.)r   zTooltip caption of the button.FzEnable or disable user changes. z1Font-awesome icon name, without the 'fa-' prefix.ZprimaryZsuccessinfoZwarningZdangerz(Use a predefined styling for the button.)valuesZdefault_valuer   r   c                s*   t t| jf | t | _| | j d S )N)superr   __init__r   _click_handlersZon_msg_handle_button_msg)selfkwargs)	__class__r   r   r!   <   s    zButton.__init__iconc             C   s.   |d }| dr*tdt |dd }|S )zStrip 'fa-' if necessary'valuezfa-zsicons names no longer start with 'fa-', just use the class name itself (for example, 'check' instead of 'fa-check')   N)
startswithwarningswarnDeprecationWarning)r$   Zproposalr(   r   r   r   _validate_iconA   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)r"   Zregister_callback)r$   callbackr/   r   r   r   on_clickK   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)r"   )r$   r   r   r   clickX   s    zButton.clickc             C   s   | dddkr|   dS )zHandle a msg from the front-end.

        Parameters
        ----------
        content: dict
            Content of the msg.
        Zeventr   r2   N)getr2   )r$   _ZcontentZbuffersr   r   r   r#   `   s    zButton._handle_button_msg)F)r   r   r   r   r   r   Z
_view_namer   ZdescriptionZtooltipr   Zdisabledr'   r   Zbutton_styler	   r   r   Zstyler!   r   r.   r1   r2   r#   __classcell__r   r   )r&   r   r      s    

r   )r   Z	domwidgetr   Zwidgetr   r   r   Zwidget_corer   Zwidget_styler   Ztrait_typesr   r	   Z	traitletsr   r   r   r   r   r   r+   r   r   r   r   r   r   <module>   s    
