ó
/¾I]c           @   s¸   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 d e	 f d „  ƒ  YZ e d e f d	 „  ƒ  Yƒ Z d
 „  Z e d e f d „  ƒ  Yƒ Z d „  Z d S(   s]   Link and DirectionalLink classes.

Propagate changes between widgets on the javascript side.
i   (   t   Widgett   registert   widget_serialization(   t
   CoreWidgetiÿÿÿÿ(   t   Unicodet   Tuplet   Instancet
   TraitErrort   WidgetTraitTuplec           B   s&   e  Z d  Z d Z d „  Z d „  Z RS(   s<   Traitlet for validating a single (Widget, 'trait_name') pairs   A (Widget, 'trait_name') pairc         K   s)   t  t |  ƒ j t t ƒ t ƒ  |  d  S(   N(   t   superR   t   __init__R   R    R   (   t   selft   kwargs(    (    s=   lib/python2.7/site-packages/ipywidgets/widgets/widget_link.pyR
      s    c         C   sš   t  t |  ƒ j | | ƒ } | \ } } | j ƒ  j | ƒ } d | j j | f } | d  k rq t d | ƒ ‚ n% | j	 j d ƒ s– t d | ƒ ‚ n  | S(   Ns   %s.%ss   No such trait: %st   syncs   %s cannot be synced(
   R	   R   t   validate_elementst   traitst   gett	   __class__t   __name__t   Nonet	   TypeErrort   metadata(   R   t   objt   valuet   widgett
   trait_namet   traitt
   trait_repr(    (    s=   lib/python2.7/site-packages/ipywidgets/widgets/widget_link.pyR      s    (   R   t
   __module__t   __doc__t	   info_textR
   R   (    (    (    s=   lib/python2.7/site-packages/ipywidgets/widgets/widget_link.pyR      s   	t   Linkc           B   st   e  Z d  Z e d ƒ j d e ƒ Z e d d ƒ j d e e  Z	 e d d ƒ j d e e  Z
 d „  Z d „  Z RS(   s“   Link Widget

    source: a (Widget, 'trait_name') tuple for the source trait
    target: a (Widget, 'trait_name') tuple that should be updated
    t	   LinkModelR   t   helps&   The target (widget, 'trait_name') pairs&   The source (widget, 'trait_name') pairc         K   s.   | | d <| | d <t  t |  ƒ j |   d  S(   Nt   sourcet   target(   R	   R   R
   (   R   R"   R#   R   (    (    s=   lib/python2.7/site-packages/ipywidgets/widgets/widget_link.pyR
   1   s    

c         C   s   |  j  ƒ  d  S(   N(   t   close(   R   (    (    s=   lib/python2.7/site-packages/ipywidgets/widgets/widget_link.pyt   unlink7   s    (   R   R   R   R   t   tagt   Truet   _model_nameR   R   R#   R"   R
   R%   (    (    (    s=   lib/python2.7/site-packages/ipywidgets/widgets/widget_link.pyR   %   s   	c         C   s   t  |  | ƒ S(   s›  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'))
    (   R   (   t   attr1t   attr2(    (    s=   lib/python2.7/site-packages/ipywidgets/widgets/widget_link.pyt   jslink;   s    t   DirectionalLinkc           B   s&   e  Z d  Z e d ƒ j d e ƒ Z RS(   s½   A 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.
    t   DirectionalLinkModelR   (   R   R   R   R   R&   R'   R(   (    (    (    s=   lib/python2.7/site-packages/ipywidgets/widgets/widget_link.pyR,   N   s   c         C   s   t  |  | ƒ S(   sŸ  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'))
    (   R,   (   R"   R#   (    (    s=   lib/python2.7/site-packages/ipywidgets/widgets/widget_link.pyt   jsdlinkY   s    N(   R   R   R    R   R   t   widget_coreR   t	   traitletsR   R   R   R   R   R   R+   R,   R.   (    (    (    s=   lib/python2.7/site-packages/ipywidgets/widgets/widget_link.pyt   <module>   s   "	
