£Á°èZ¨Ä…–K§‚«“ô4“ÒÙ´dîfUÙÃÅ WKbyÊ¦•êŽ…È®FÒ¿ÊÎóCozá¬S@6{Í:›œêZÌ:Š•_%:¢¾¾~;‘Ã~èŠ©ÊÇí`ÔÑ©úë™µ'5I¿fš×WO%ø9¾«¾DK|€ùÍD”Ýs]nHÕ¶ê×Ó¼ãžªéUWŸÈË%DÒÕ¬ï‘]/Åcx  ‰ï2ß]ä6G[]S£ÔÏ¯rs{úëóµmÒï#UQxo·õÞCe]"±/aÙ&Eã4ú9Jé_ÞåëdãöKë)AÞ                  ¯¹ægƒÛowÐø^d™ý½ßB7áyMä9ÜÖUã
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
<html>
B
     f                 @   s   d Z ddlmZmZmZmZ ddlmZ dZdZ	dZ
dZdZd	ZG d
d deZdd ZedkrddlmZ edddd ddlmZ ee dS )zvA call-tip window class for Tkinter/IDLE.

After tooltip.py, which uses ideas gleaned from PySol.
Used by calltip.py.
    )LabelLEFTSOLIDTclError)TooltipBasez<<calltipwindow-hide>>)z<Key-Escape>z
<FocusOut>z<<calltipwindow-checkhide>>)z<KeyRelease>z<ButtonRelease>d   Zcalltipwindowregion_rightc                   sv   e Zd ZdZ fddZdd Z fddZ fdd	Zd
d ZdddZ	dd Z
 fddZdd Zdd Z  ZS )CalltipWindowz+A call-tip widget for tkinter text widgets.c                sD   t t| | d | _| _d | _ | _| _d | _| _	d| _
dS )z}Create a call-tip; shown by showtip().

        text_widget: a Text widget with code for which call-tips are desired
        N)superr   __init__labeltext	parenlineparencollastlinehideidcheckhideidcheckhide_after_id)selfZtext_widget)	__class__ 6/opt/alt/python37/lib64/python3.7/idlelib/calltip_w.pyr
      s
    zCalltipWindow.__init__c             C   s   t | jddd }|| jkr2| j| jf}n|df}| jd| }|snt| jd}d|d< d|d< |d d |d |d  fS )z$Choose the position of the call-tip.insert.r   z%d.%d         )intanchor_widgetindexsplitr   r   Zbboxlist)r   curlineZanchor_indexZboxr   r   r   get_position#   s    
zCalltipWindow.get_positionc                sL   t | jddd }|| jkr(dS || _| jd tt|   dS )z Reposition the window if needed.r   r   r   N)	r   r   r   r   r   Zseer	   r   position_window)r   r!   )r   r   r   r#   2   s    
zCalltipWindow.position_windowc                s^   || _ | js| j sdS | jt| tt| j|d\| _	| _
tt|   |   dS )a_  Show the call-tip, bind events which will close it and reposition it.

        text: the text to display in the call-tip
        parenleft: index of the opening parenthesis in the text widget
        parenright: index of the closing parenthesis in the text widget,
                    or the end of the line if there is no closing parenthesis
        Nr   )r   	tipwindowr   Zmark_set
MARK_RIGHTmapr   r   r   r   r   r	   r   showtip_bind_events)r   r   Z	parenleftZ
parenright)r   r   r   r'   ;   s    	zCalltipWindow.showtipc          
   C   s2   t | j| jtddtd| jd d| _| j  dS )zCreate the call-tip widget.z#ffffd0Zblackr   font)r   ZjustifyZ
backgroundZ
foregroundZreliefZborderwidthr)   N)r   r$   r   r   r   r   r   pack)r   r   r   r   showcontentsP   s
    zCalltipWindow.showcontentsNc             C   s   | j s
dS tt| jdd\}}|| jk sT|| jkrD|| jksT| jddt	r`| 
  dS |   | jdk	r| j| j | jt| j| _dS )z4Handle CHECK_HIDE_EVENT: call hidetip or reschedule.Nr   r   >break)r$   r&   r   r   r   r   r   r   Zcomparer%   hidetipr#   r   Zafter_cancelafterCHECKHIDE_TIMEcheckhide_event)r   eventr!   Zcurcolr   r   r   r1   X   s    

zCalltipWindow.checkhide_eventc             C   s   | j s
dS |   dS )z%Handle HIDE_EVENT by calling hidetip.Nr-   )r$   r.   )r   r2   r   r   r   
hide_events   s    zCalltipWindow.hide_eventc          	      s   | j s
dS y| j  W n tk
r,   Y nX d| _d | _ | _| _y| jt	 W n tk
rj   Y nX y| 
  W n ttfk
r   Y nX tt|   dS )zHide the call-tip.N)r$   r   Zdestroyr   r   r   r   r   Z
mark_unsetr%   _unbind_events
ValueErrorr	   r   r.   )r   )r   r   r   r.   {   s"    zCalltipWindow.hidetipc             C   sp   | j t| j| _xtD ]}| j t| qW | j t| j | j t	| j
| _xtD ]}| j t	| qVW dS )zBind event handlers.N)r   bindCHECKHIDE_EVENTr1   r   CHECKHIDE_SEQUENCES	event_addr/   r0   
HIDE_EVENTr3   r   HIDE_SEQUENCES)r   seqr   r   r   r(      s    



zCalltipWindow._bind_eventsc             C   sh   xt D ]}| jt| qW | jt| j d| _xtD ]}| jt| q8W | jt| j d| _dS )zUnbind event handlers.N)	r8   r   Zevent_deleter7   Zunbindr   r;   r:   r   )r   r<   r   r   r   r4      s    

zCalltipWindow._unbind_events)N)__name__
__module____qualname____doc__r
   r"   r#   r'   r+   r1   r3   r.   r(   r4   __classcell__r   r   )r   r   r      s   	
r   c                s   ddl m}m}m}m} || }|d tt|  	ddd  \}}|d|d |d f  ||}|j
||dd	 |d
d |  t|  fdd}	 fdd}
|dd |dd |d|	 |d|
 |  d S )Nr   )ToplevelTextr   BOTHzTest call-tips+r   z250x100+%d+%d      )ZsideZfillexpandr   zstring.splitc                s     ddd d S )Nz(s='Hello world')r   end)r'   )r2   )calltipr   r   calltip_show   s    z%_calltip_window.<locals>.calltip_showc                s       d S )N)r.   )r2   )rJ   r   r   calltip_hide   s    z%_calltip_window.<locals>.calltip_hidez<<calltip-show>>(z<<calltip-hide>>))tkinterrB   rC   r   rD   titler&   r   Zgeometryr   r*   r   updater   r9   r6   Z	focus_set)parentrB   rC   r   rD   topxyr   rK   rL   r   )rJ   r   _calltip_window   s"    
 rV   __main__)mainz idlelib.idle_test.test_calltip_wr   F)	verbosityexit)runN)r@   rO   r   r   r   r   Zidlelib.tooltipr   r:   r;   r7   r8   r0   r%   r   rV   r=   ZunittestrX   Zidlelib.idle_test.htestr[   r   r   r   r   <module>   s     