<!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
 fV                 @   s~   d Z ddlT G dd deZG dd deZG dd deZd	d
 Zedkrzddlm	Z	 e	dddd ddl
mZ ee dS )zTools for displaying tool-tips.

This includes:
 * an abstract base-class for different kinds of tooltips
 * a simple text-only Tooltip class
    )*c               @   sH   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dS )TooltipBasez abstract base class for tooltipsc             C   s   || _ d| _dS )zCreate a tooltip.

        anchor_widget: the widget next to which the tooltip will be shown

        Note that a widget will only be shown when showtip() is called.
        N)anchor_widget	tipwindow)selfr    r   4/opt/alt/python36/lib64/python3.6/idlelib/tooltip.py__init__   s    zTooltipBase.__init__c             C   s   | j   d S )N)hidetip)r   r   r   r   __del__   s    zTooltipBase.__del__c             C   s|   | j r
dS t| j | _ }|jd y|jjdd|jdd W n tk
rR   Y nX | j  | j	  | j j
  | j j  dS )zdisplay the tooltipN   z!::tk::unsupported::MacWindowStyleZstylehelpZnoActivates)r   Toplevelr   Zwm_overrideredirectZtkZcallZ_wTclErrorposition_windowshowcontentsZupdate_idletasksZlift)r   twr   r   r   showtip   s    

zTooltipBase.showtipc             C   s@   | j  \}}| jj | }| jj | }| jjd||f  dS )z&(re)-set the tooltip's screen positionz+%d+%dN)get_positionr   Zwinfo_rootxZwinfo_rootyr   Zwm_geometry)r   xyZroot_xZroot_yr   r   r   r   /   s    zTooltipBase.position_windowc             C   s   d| j j d fS )z(choose a screen position for the tooltip   r   )r   Zwinfo_height)r   r   r   r   r   6   s    	zTooltipBase.get_positionc             C   s   t dS )z$content display hook for sub-classesN)NotImplementedError)r   r   r   r   r   A   s    zTooltipBase.showcontentsc             C   s6   | j }d| _ |r2y|j  W n tk
r0   Y nX dS )zhide the tooltipN)r   Zdestroyr   )r   r   r   r   r   r
   F   s    zTooltipBase.hidetipN)__name__
__module____qualname____doc__r	   r   r   r   r   r   r
   r   r   r   r   r   
   s   
r   c                   s^   e Zd ZdZd fdd	Z fddZddd	Zdd
dZdd Zdd Z	 fddZ
  ZS )OnHoverTooltipBasez?abstract base class for tooltips, with delayed on-hover display  c                sV   t t| j| || _d| _| jjd| j| _| jjd| j	| _
| jjd| j	| _dS )aq  Create a tooltip with a mouse hover delay.

        anchor_widget: the widget next to which the tooltip will be shown
        hover_delay: time to delay before showing the tooltip, in milliseconds

        Note that a widget will only be shown when showtip() is called,
        e.g. after hovering over the anchor widget with the mouse for enough
        time.
        Nz<Enter>z<Leave>z<Button>)superr   r	   hover_delay	_after_idr   Zbind_show_event_id1_hide_event_id2_id3)r   r   r    )	__class__r   r   r	   U   s    
zOnHoverTooltipBase.__init__c                s\   y4| j jd| j | j jd| j | j jd| j W n tk
rH   Y nX tt| j  d S )Nz<Enter>z<Leave>z<Button>)	r   Zunbindr#   r%   r&   r   r   r   r   )r   )r'   r   r   r   g   s    zOnHoverTooltipBase.__del__Nc             C   s   | j r| j  n| j  dS )z$event handler to display the tooltipN)r    scheduler   )r   eventr   r   r   r"   p   s    
zOnHoverTooltipBase._show_eventc             C   s   | j   dS )z!event handler to hide the tooltipN)r
   )r   r)   r   r   r   r$   w   s    zOnHoverTooltipBase._hide_eventc             C   s    | j   | jj| j| j| _dS )z*schedule the future display of the tooltipN)
unscheduler   afterr    r   r!   )r   r   r   r   r(   {   s    
zOnHoverTooltipBase.schedulec             C   s    | j }d| _ |r| jj| dS )z(cancel the future display of the tooltipN)r!   r   Zafter_cancel)r   Zafter_idr   r   r   r*      s    zOnHoverTooltipBase.unschedulec                s4   y| j   W n tk
r    Y nX tt| j  dS )zhide the tooltipN)r*   r   r   r   r
   )r   )r'   r   r   r
      s
    zOnHoverTooltipBase.hidetip)r   )N)N)r   r   r   r   r	   r   r"   r$   r(   r*   r
   __classcell__r   r   )r'   r   r   R   s   	

r   c                   s*   e Zd ZdZd fdd	Zdd Z  ZS )HovertipzAA tooltip that pops up when a mouse hovers over an anchor widget.  c                s   t t| j||d || _dS )av  Create a text tooltip with a mouse hover delay.

        anchor_widget: the widget next to which the tooltip will be shown
        hover_delay: time to delay before showing the tooltip, in milliseconds

        Note that a widget will only be shown when showtip() is called,
        e.g. after hovering over the anchor widget with the mouse for enough
        time.
        )r    N)r   r-   r	   text)r   r   r/   r    )r'   r   r   r	      s    
zHovertip.__init__c             C   s$   t | j| jtdtdd}|j  d S )Nz#ffffe0r   )r/   ZjustifyZ
backgroundZreliefZborderwidth)Labelr   r/   ZLEFTZSOLIDpack)r   labelr   r   r   r      s    zHovertip.showcontents)r.   )r   r   r   r   r	   r   r,   r   r   )r'   r   r-      s   r-   c             C   s   t | }|jd tt| j jddd  \}}|jd||d f  t|dd}|j  t|dd}|j  t	|d	d
d t|dd}|j  t	|dd d d S )NzTest tooltip+r   z+%d+%d   zPlace your mouse over buttons)r/   z"Button 1 -- 1/2 second hover delayz!This is tooltip text for button1.i  )r    zButton 2 -- no hover delayz!This is tooltip
text for button2.)
r   titlemapintZgeometrysplitr0   r1   ZButtonr-   )parenttopr   r   r2   Zbutton1Zbutton2r   r   r   _tooltip   s    
 r;   __main__)mainzidlelib.idle_test.test_tooltip   F)	verbosityexit)runN)r   Ztkinterobjectr   r   r-   r;   r   Zunittestr=   Zidlelib.idle_test.htestrA   r   r   r   r   <module>   s   H?