
    ^h|                         S r SSKJrJrJr  SSKJr  SSKJrJ	r	J
r
Jr   " S S\	5      r\ " S S	\5      5       rS
 r\ " S S\5      5       rS rg)z]Link and DirectionalLink classes.

Propagate changes between widgets on the javascript side.
   )Widgetregisterwidget_serialization)
CoreWidget    )UnicodeTupleInstance
TraitErrorc                   <   ^  \ rS rSrSrSrU 4S jrU 4S jrSrU =r	$ )WidgetTraitTuple   z<Traitlet for validating a single (Widget, 'trait_name') pairzA (Widget, 'trait_name') pairc                    > [         TU ]  " [        [        5      [	        5       40 UD6  SU;  a   UR                  SS5      (       d  SU l        g g g )Ndefault_value
allow_noneF )super__init__r
   r   r   getdefault_args)selfkwargs	__class__s     X/home/james-whalen/.local/lib/python3.13/site-packages/ipywidgets/widgets/widget_link.pyr   WidgetTraitTuple.__init__   sI    &)79??&(L%1P1P
 !#D 2Q(    c                 6  > [         TU ]  X5      nUu  p4UR                  5       R                  U5      nSR	                  UR
                  R                  U5      nUc  [        SU-  5      eUR                  R                  S5      (       d  [        SU-  5      eU$ )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   "WidgetTraitTuple.validate_elements   s    )#5"##J/^^F$4$4$=$=zJ
 =/*<==##F++1J>??r   )r   )
r"   
__module____qualname____firstlineno____doc__	info_textr   r   __static_attributes____classcell__r   s   @r   r   r      s    F/I# r   r   c                      ^  \ rS rSrSr\" S5      R                  SS9r\" SS9R                  " SSS0\	D6r
\" S	S9R                  " SSS0\	D6rU 4S
 jrS rSrU =r$ )Link+   zLink 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                 6   > XS'   X#S'   [         TU ]  " S0 UD6  g )Nsourcetargetr   )r   r   )r   r;   r<   r   r   s       r   r   Link.__init__7   s#    !x!x"6"r   c                 $    U R                  5         g )N)close)r   s    r   unlinkLink.unlink=   s    

r   r   )r"   r,   r-   r.   r/   r   tag_model_namer   r   r<   r;   r   r@   r1   r2   r3   s   @r   r5   r5   +   sq     +&***5K#KLPPsVZs^rsF#KLPPsVZs^rsF# r   r5   c                     [        X5      $ )as  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'))
)r5   )attr1attr2s     r   jslinkrG   A   s      r   c                   B    \ rS rSrSr\" S5      R                  SS9rSrg)DirectionalLinkT   zA 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.
DirectionalLinkModelTr8   r   N)	r"   r,   r-   r.   r/   r   rB   rC   r1   r   r   r   rI   rI   T   s"     015545@Kr   rI   c                     [        X5      $ )aw  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'))
)rI   )r;   r<   s     r   jsdlinkrM   _   s      6**r   N)r/   r'   r   r   r   widget_corer   	traitletsr   r	   r
   r   r   r5   rG   rI   rM   r   r   r   <module>rP      sj   
 ; : # : :u 8 
:  
*& 
Ad A 
A+r   