<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
3
 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>><Key-Escape>
<FocusOut>z<<calltipwindow-checkhide>><KeyRelease><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| j| 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/python36/lib64/python3.6/idlelib/calltip_w.pyr      s
    zCalltipWindow.__init__c             C   s   t | jjdjdd }|| jkr2| j| jf}n|df}| jjd| }|snt| j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jdjdd }|| jkr(dS || _| jjd tt| j  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  rdS | jjt| tt| jj|jd\| _	| _
tt| j  | j  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   s0   t | j| jtdtd| jd d| _| jj  dS )zCreate the call-tip widget.z#ffffe0r   font)r   ZjustifyZ
backgroundZ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jdjd\}}|| jk sT|| jkrD|| jksT| jjddt	r`| j
  dS | j  | jdk	r| jj| 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   r5   W   s    

zCalltipWindow.checkhide_eventc             C   s   | j s
dS | j  dS )z%Handle HIDE_EVENT by calling hidetip.Nr1   )r(   r2   )r   r6   r   r   r   
hide_eventr   s    zCalltipWindow.hide_eventc                s   | j s
dS y| jj  W n tk
r,   Y nX d| _d | _ | _| _y| jjt	 W n tk
rj   Y nX y| j
  W n ttfk
r   Y nX tt| j  dS )zHide the call-tip.N)r(   r   Zdestroyr   r   r   r   r!   Z
mark_unsetr)   _unbind_events
ValueErrorr   r   r2   )r   )r   r   r   r2   z   s"    zCalltipWindow.hidetipc             C   sp   | j jt| j| _xtD ]}| j jt| qW | j jt| j | j jt	| j
| _xtD ]}| j jt	| qVW dS )zBind event handlers.N)r!   bindCHECKHIDE_EVENTr5   r   CHECKHIDE_SEQUENCES	event_addr3   r4   
HIDE_EVENTr7   r   HIDE_SEQUENCES)r   seqr   r   r   r,      s    



zCalltipWindow._bind_eventsc             C   sh   xt D ]}| jjt| qW | jjt| j d| _xtD ]}| jjt| q8W | jjt| j d| _dS )zUnbind event handlers.N)	r<   r!   Zevent_deleter;   Zunbindr   r?   r>   r   )r   r@   r   r   r   r8      s    

zCalltipWindow._unbind_events)N)__name__
__module____qualname____doc__r   r&   r'   r+   r/   r5   r7   r2   r,   r8   __classcell__r   r   )r   r   r      s   	
r   c                s   ddl m}m}m}m} || }|jd tt| j j	ddd  \}}|jd|d |d f  ||}|j
||dd	 |jd
d |j  t|  fdd}	 fdd}
|jdd |jdd |jd|	 |jd|
 |j  d S )Nr   )ToplevelTextr   BOTHzTest call-tips+r   z250x100+%d+%d      )ZsideZfillexpandr   zstring.splitc                s    j ddd d S )Nz(s='Hello world')r   end)r+   )r6   )calltipr   r   calltip_show   s    z%_calltip_window.<locals>.calltip_showc                s    j   d S )N)r2   )r6   )rN   r   r   calltip_hide   s    z%_calltip_window.<locals>.calltip_hidez<<calltip-show>>(z<<calltip-hide>>))tkinterrF   rG   r   rH   titler*   r    Zgeometryr#   r.   r   updater   r=   r:   Z	focus_set)parentrF   rG   r   rH   topxyr   rO   rP   r   )rN   r   _calltip_window   s"    
 rZ   __main__)mainz idlelib.idle_test.test_calltip_wr   F)	verbosityexit)runN)r   r   )r	   r
   )rD   rS   r   r   r   r   Zidlelib.tooltipr   r>   r?   r;   r<   r4   r)   r   rZ   rA   Zunittestr\   Zidlelib.idle_test.htestr_   r   r   r   r   <module>   s     