ó
Š]c           @   s›   d  Z  d d l m Z m Z m Z m Z m Z d Z d Z d Z	 d Z
 d	 Z d
 Z d d d „  ƒ  YZ d „  Z e d k r— d d l m Z e e ƒ n  d S(   s…   A CallTip window class for Tkinter/IDLE.

After ToolTip.py, which uses ideas gleaned from PySol
Used by the CallTips IDLE extension.
iÿÿÿÿ(   t   Toplevelt   Labelt   LEFTt   SOLIDt   TclErrors   <<calltipwindow-hide>>s   <Key-Escape>s
   <FocusOut>s   <<calltipwindow-checkhide>>s   <KeyRelease>s   <ButtonRelease>id   t   calltipwindowregion_rightt   CallTipc           B   sJ   e  Z d  „  Z d „  Z d „  Z d d „ Z d „  Z d „  Z d „  Z	 RS(   c         C   sO   | |  _  d  |  _ |  _ d  |  _ |  _ d  |  _ d  |  _ |  _ d  |  _	 d  S(   N(
   t   widgett   Nonet	   tipwindowt   labelt	   parenlinet   parencolt   lastlinet   hideidt   checkhideidt   checkhide_after_id(   t   selfR   (    (    s&   lib/python2.7/idlelib/CallTipWindow.pyt   __init__   s    		c         C   s(  t  |  j j d ƒ j d ƒ d ƒ } | |  j k r8 d S| |  _ |  j j d ƒ | |  j k r… |  j j d |  j |  j f ƒ } n |  j j d | ƒ } | sÐ t	 |  j j d ƒ ƒ } d | d <d | d <n  | d |  j j
 ƒ  d } | d | d	 |  j j ƒ  } |  j j d
 | | f ƒ d S(   s;   Check if needs to reposition the window, and if so - do it.t   insertt   .i    Ns   %d.%ds   %d.0i   i   i   s   +%d+%d(   t   intR   t   indext   splitR   t   seeR   t   bboxR   t   listt   winfo_rootxt   winfo_rootyR	   t   wm_geometry(   R   t   curlinet   boxt   xt   y(    (    s&   lib/python2.7/idlelib/CallTipWindow.pyt   position_window   s     %	
c         C   s½  | |  _  |  j s |  j  r  d S|  j j t | ƒ t t |  j j | ƒ j d ƒ ƒ \ |  _	 |  _
 t |  j ƒ |  _ } |  j ƒ  | j d ƒ y# | j j d d | j d d ƒ Wn t k
 rÆ n Xt | d |  j  d	 t d
 d d t d d d |  j d ƒ|  _ |  j j ƒ  | j ƒ  | j ƒ  |  j j t |  j ƒ |  _ x! t D] } |  j j t | ƒ qGW|  j j t  |  j ƒ |  j j t! |  j" ƒ |  _# x! t$ D] } |  j j t! | ƒ qœWd S(   sM   Show the calltip, bind events which will close it and reposition it.
        NR   i   s!   ::tk::unsupported::MacWindowStylet   stylet   helpt   noActivatest   textt   justifyt
   backgrounds   #ffffe0t   relieft   borderwidtht   font(%   R&   R	   R   t   mark_sett
   MARK_RIGHTt   mapR   R   R   R   R   R    R"   t   wm_overrideredirectt   tkt   callt   _wR   R   R   R   R
   t   packt   update_idletaskst   liftt   bindt   CHECKHIDE_VIRTUAL_EVENT_NAMEt   checkhide_eventR   t   CHECKHIDE_SEQUENCESt	   event_addt   aftert   CHECKHIDE_TIMEt   HIDE_VIRTUAL_EVENT_NAMEt
   hide_eventR   t   HIDE_SEQUENCES(   R   R&   t	   parenleftt
   parenrightt   twt   seq(    (    s&   lib/python2.7/idlelib/CallTipWindow.pyt   showtip/   s:    	-


c         C   s×   |  j  s d  St t |  j j d ƒ j d ƒ ƒ \ } } | |  j k  s| | |  j k rd | |  j k s| |  j j d d t	 ƒ r‰ |  j
 ƒ  nJ |  j ƒ  |  j d  k	 r¸ |  j j |  j ƒ n  |  j j t |  j ƒ |  _ d  S(   NR   R   t   >(   R	   R.   R   R   R   R   R   R   t   compareR-   t   hidetipR"   R   R   t   after_cancelR;   R<   R8   (   R   t   eventR   t   curcol(    (    s&   lib/python2.7/idlelib/CallTipWindow.pyR8   X   s    	*
c         C   s   |  j  s d  S|  j ƒ  d  S(   N(   R	   RG   (   R   RI   (    (    s&   lib/python2.7/idlelib/CallTipWindow.pyR>   j   s    	c         C   sê   |  j  s d  Sx! t D] } |  j j t | ƒ q W|  j j t |  j ƒ d  |  _ x! t D] } |  j j t	 | ƒ qW W|  j j t	 |  j
 ƒ d  |  _
 |  j j ƒ  d  |  _ |  j  j ƒ  d  |  _  |  j j t ƒ d  |  _ |  _ |  _ d  S(   N(   R	   R9   R   t   event_deleteR7   t   unbindR   R   R?   R=   R   R
   t   destroyt
   mark_unsetR-   R   R   R   (   R   RC   (    (    s&   lib/python2.7/idlelib/CallTipWindow.pyRG   p   s     					c         C   s   t  |  j ƒ S(   N(   t   boolR	   (   R   (    (    s&   lib/python2.7/idlelib/CallTipWindow.pyt	   is_active…   s    N(
   t   __name__t
   __module__R   R"   RD   R   R8   R>   RG   RP   (    (    (    s&   lib/python2.7/idlelib/CallTipWindow.pyR      s   			)		c   	         s   d d l  m } m } m } m } | |  ƒ } | j d ƒ | j d |  j ƒ  d |  j ƒ  d f ƒ | | ƒ } | j	 d | d | d	 d
 ƒ | j
 d d ƒ | j ƒ  t | ƒ ‰  ‡  f d †  } ‡  f d †  } | j d d ƒ | j d d ƒ | j d | ƒ | j d | ƒ | j ƒ  d  S(   Niÿÿÿÿ(   R    t   TextR   t   BOTHs   Test calltipss   200x100+%d+%diÈ   i–   t   sidet   fillt   expandi   R   s   string.splitc            s   ˆ  j  d d d ƒ d  S(   Ns   (s=Hello world)R   t   end(   RD   (   RI   (   t   calltip(    s&   lib/python2.7/idlelib/CallTipWindow.pyt   calltip_show–   s    c            s   ˆ  j  ƒ  d  S(   N(   RG   (   RI   (   RY   (    s&   lib/python2.7/idlelib/CallTipWindow.pyt   calltip_hide˜   s    s   <<calltip-show>>t   (s   <<calltip-hide>>t   )(   t   TkinterR    RS   R   RT   t   titlet   geometryR   R   R3   R   t   updateR   R:   R6   t	   focus_set(	   t   parentR    RS   R   RT   t   topR&   RZ   R[   (    (   RY   s&   lib/python2.7/idlelib/CallTipWindow.pyt   _calltip_window‰   s"    "
t   __main__(   t   runN(   s   <Key-Escape>s
   <FocusOut>(   s   <KeyRelease>s   <ButtonRelease>(    (   t   __doc__R^   R    R   R   R   R   R=   R?   R7   R9   R<   R-   R   Re   RQ   t   idlelib.idle_test.htestRg   (    (    (    s&   lib/python2.7/idlelib/CallTipWindow.pyt   <module>   s   (y	