
    ge2                         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e
e                      Ze G 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                       e Zd ZdZ ed                              d          Z eddd                              d          Z ed	                              d          Z	dS )
ButtonStylezButton style widget.ButtonStyleModelTsyncNzColor of the button)
allow_nonehelpzButton text font weight.r   )
__name__
__module____qualname____doc__r   tag_model_namer	   button_colorfont_weight     @lib/python3.11/site-packages/ipywidgets/widgets/widget_button.pyr   r      s        ',--11t1<<K5$5JKKKOOUYOZZL'9:::>>D>IIKKKr#   r   c                   V    e Zd ZdZ ed                              d          Z ed                              d          Z ed                              d          Z ed                              d          Z	 e
d	d
                              d          Z edd                              d          Z eg ddd                              d          Z  ee          j        dddieZ fdZ ed          d             ZddZd Zd Z x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
    
ButtonViewTr   ButtonModelzButton label.r   zTooltip caption of the button.FzEnable or disable user changes. z1Font-awesome icon name, without the 'fa-' prefix.)primarysuccessinfowarningdangerr)   z(Use a predefined styling for the button.)valuesdefault_valuer   r   c                      t          t          |           j        di | t                      | _        |                     | j                   d S )Nr"   )superr&   __init__r   _click_handlerson_msg_handle_button_msg)selfkwargs	__class__s     r$   r3   zButton.__init__<   sO    $fd$..v...133D+,,,,,r#   iconc                     |d         }|                     d          r$t          j        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)r7   proposalr<   s      r$   _validate_iconzButton._validate_iconA   sV     !E"" 	M Z[mo o o!""IEr#   c                 >    | j                             ||           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)r4   register_callback)r7   callbackrE   s      r$   on_clickzButton.on_clickK   s&     	..x.GGGGGr#   c                 0    |                      |            dS )zProgrammatically trigger a click event.

        This will call the callbacks registered to the clicked button
        widget instance.
        N)r4   )r7   s    r$   clickzButton.clickX   s     	T"""""r#   c                 f    |                     dd          dk    r|                                  dS dS )zHandle a msg from the front-end.

        Parameters
        ----------
        content: dict
            Content of the msg.
        eventr)   rJ   N)getrJ   )r7   _contentbufferss       r$   r6   zButton._handle_button_msg`   s6     ;;w##w..JJLLLLL /.r#   r"   )F)r   r   r   r   r   r   
_view_namer   descriptiontooltipr   disabledr:   r   button_styler
   r   r   styler3   r   rC   rH   rJ   r6   __classcell__)r9   s   @r$   r&   r&      s          &&***55J'-((,,$,77K'///333>>Kg;<<<@@d@KKGtE ABBBFFDFQQH72OPPPTTZ^T__D"?FFFVX;= = ==@SdS^^  *LL%%)LLtL7KLLE- - - - -
 Xf  H H H H# # #	 	 	 	 	 	 	r#   r&   )r   	domwidgetr   widgetr   r   r   widget_corer   widget_styler   trait_typesr	   r
   	traitletsr   r   r   r   r   r   r?   r   r&   r"   r#   r$   <module>r^      sB    !           F F F F F F F F F F # # # # # #       , , , , , , , , Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q  
J J J J J% J J 
J 
L L L L LY
 L L 
L L Lr#   