
    hMh|                         d Z ddlmZmZmZ ddlmZ ddlmZm	Z	m
Z
mZ  G d de	          Ze G d d	e                      Zd
 Ze G d de                      Zd ZdS )z]Link and DirectionalLink classes.

Propagate changes between widgets on the javascript side.
   )Widgetregisterwidget_serialization)
CoreWidget    )UnicodeTupleInstance
TraitErrorc                   0     e Zd ZdZdZ fdZ fdZ xZS )WidgetTraitTuplez<Traitlet for validating a single (Widget, 'trait_name') pairzA (Widget, 'trait_name') pairc                      t                      j        t          t                    t	                      fi | d|vr|                    dd          sd| _        d S d S d S )Ndefault_value
allow_noneF )super__init__r
   r   r   getdefault_args)selfkwargs	__class__s     ^/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/ipywidgets/widgets/widget_link.pyr   zWidgetTraitTuple.__init__   sl    &))799?????&((L%1P1P(
 !#D )(((    c                 d   t                                          ||          }|\  }}|                                                    |          }d                    |j        j        |          }|t          d|z            |j                            d          st          d|z            |S )Nz{}.{}zNo such trait: %ssyncz%s cannot be synced)	r   validate_elementstraitsr   formatr   __name__	TypeErrormetadata)r   objvaluewidget
trait_nametrait
trait_reprr   s          r   r   z"WidgetTraitTuple.validate_elements   s    ))#u55"
##J//^^F$4$=zJJ
 =/*<===##F++ 	@1J>???r   )r    
__module____qualname____doc__	info_textr   r   __classcell__r   s   @r   r   r      s\        FF/I# # # # #        r   r   c                        e Zd ZdZ ed                              d          Z  ed          j        dddieZ	  ed          j        dddieZ
 fd	Zd
 Z xZS )LinkzLink Widget

    source: a (Widget, 'trait_name') tuple for the source trait
    target: a (Widget, 'trait_name') tuple that should be updated
    	LinkModelTr   z&The target (widget, 'trait_name') pair)helpr   z&The source (widget, 'trait_name') pairc                 N    ||d<   ||d<    t                      j        di | d S )Nsourcetargetr   )r   r   )r   r5   r6   r   r   s       r   r   zLink.__init__7   s:    !x!x""6"""""r   c                 .    |                                   d S )N)close)r   s    r   unlinkzLink.unlink=   s    

r   r   )r    r)   r*   r+   r   tag_model_namer   r   r6   r5   r   r9   r-   r.   s   @r   r0   r0   +   s          '+&&***55KP#KLLLPssVZs^rssFP#KLLLPssVZs^rssF# # # # #      r   r0   c                 "    t          | |          S )a  Link two widget attributes on the frontend so they remain in sync.

    The link is created in the front-end and does not rely on a roundtrip
    to the backend.

    Parameters
    ----------
    source : a (Widget, 'trait_name') tuple for the first trait
    target : a (Widget, 'trait_name') tuple for the second trait

    Examples
    --------

    >>> c = link((widget1, 'value'), (widget2, 'value'))
    )r0   )attr1attr2s     r   jslinkr?   A   s      ur   c                   P    e Zd ZdZ ed                              d          ZdS )DirectionalLinkzA directional link

    source: a (Widget, 'trait_name') tuple for the source trait
    target: a (Widget, 'trait_name') tuple that should be updated
    when the source trait changes.
    DirectionalLinkModelTr2   N)r    r)   r*   r+   r   r:   r;   r   r   r   rA   rA   T   s;          '0115545@@KKKr   rA   c                 "    t          | |          S )a  Link a source widget attribute with a target widget attribute.

    The link is created in the front-end and does not rely on a roundtrip
    to the backend.

    Parameters
    ----------
    source : a (Widget, 'trait_name') tuple for the source trait
    target : a (Widget, 'trait_name') tuple for the target trait

    Examples
    --------

    >>> c = dlink((src_widget, 'value'), (tgt_widget, 'value'))
    )rA   )r5   r6   s     r   jsdlinkrD   _   s      66***r   N)r+   r%   r   r   r   widget_corer   	traitletsr   r	   r
   r   r   r0   r?   rA   rD   r   r   r   <module>rG      s+   
 ; : : : : : : : : : # # # # # # : : : : : : : : : : : :    u   8 
    :   
*  & 
A A A A Ad A A 
A+ + + + +r   