
   qI=                       S r SSK7   " S S5      r " S S\5      r " S S\5      rS	 r\S
:X  a  SSKJr  \" SSSS9  SSK	J
r
  \
" \5        gg)zTools for displaying tool-tips.

This includes:
 * an abstract base-class for different kinds of tooltips
 * a simple text-only Tooltip class
    )*c                   B    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
rg)TooltipBase
   z abstract base class for tooltipsc                     Xl         SU l        g)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	   s     &/usr/lib/python3.13/idlelib/tooltip.py__init__TooltipBase.__init__   s     +    c                 $    U R                  5         g Nhidetipr   s    r   __del__TooltipBase.__del__   s    r   c                    U R                   (       a  g[        U R                  5      =U l         nUR                  S5         UR                  R                  SSUR                  SS5        U R                  5         U R                  5         U R                   R                  5         U R                   R                  5         g! [         a     Naf = f)zdisplay the tooltipN   z!::tk::unsupported::MacWindowStylestylehelpnoActivates)r
   Toplevelr	   wm_overrideredirecttkcall_wTclErrorposition_windowshowcontentsupdate_idletasksliftr   tws     r   showtipTooltipBase.showtip   s    >>&t'9'9::
q!	 EEJJ:GRUU}.
 	'')  		s   )B? ?
CCc                     U R                  5       u  pU R                  R                  5       U-   nU R                  R                  5       U-   nU R                  R                  SX44-  5        g)z&(re)-set the tooltip's screen position+%d+%dN)get_positionr	   winfo_rootxwinfo_rootyr
   wm_geometry)r   xyroot_xroot_ys        r   r"   TooltipBase.position_window/   s^      "##//1A5##//1A5""8v.>#>?r   c                 @    SU R                   R                  5       S-   4$ )z(choose a screen position for the tooltip   r   )r	   winfo_heightr   s    r   r,   TooltipBase.get_position6   s#     4%%224q888r   c                     [         e)z$content display hook for sub-classes)NotImplementedErrorr   s    r   r#   TooltipBase.showcontentsA   s
     "!r   c                 |    U R                   nSU l         U(       a   UR                  5         gg! [         a     gf = fzhide the tooltipN)r
   destroyr!   r&   s     r   r   TooltipBase.hidetipF   s>     ^^

   s   . 
;;r   N)__name__
__module____qualname____firstlineno____doc__r   r   r(   r"   r,   r#   r   __static_attributes__ r   r   r   r   
   s)    **@	9"
	r   r   c                   h   ^  \ rS rSrSrSU 4S jjrU 4S jrSS jrSS jrS r	S r
U 4S	 jrS
rU =r$ )OnHoverTooltipBaseR   z?abstract base class for tooltips, with delayed on-hover displayc                 @  > [         TU ]  U5        X l        SU l        U R                  R                  SU R                  5      U l        U R                  R                  SU R                  5      U l	        U R                  R                  SU R                  5      U l
        g)aA  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.
N<Enter><Leave><Button>)superr   hover_delay	_after_idr	   bind_show_event_id1_hide_event_id2_id3)r   r	   rO   	__class__s      r   r   OnHoverTooltipBase.__init__U   s     	'&&&++It7G7GH	&&++It7G7GH	&&++J8H8HI	r   c                 (  >  U R                   R                  SU R                  5        U R                   R                  SU R                  5        U R                   R                  SU R                  5        [        TU ]  5         g ! [
         a     Nf = f)NrK   rL   rM   )r	   unbindrS   rU   rV   r!   rN   r   r   rW   s    r   r   OnHoverTooltipBase.__del__g   sv    	%%i;%%i;%%j$))< 	  		s   A2B 
BBc                 h    U R                   (       a  U R                  5         gU R                  5         g)z$event handler to display the tooltipN)rO   scheduler(   r   events     r   rR   OnHoverTooltipBase._show_eventp   s    MMOLLNr   c                 $    U R                  5         g)z!event handler to hide the tooltipNr   r_   s     r   rT   OnHoverTooltipBase._hide_eventw   s    r   c                     U R                  5         U R                  R                  U R                  U R                  5      U l        g)z*schedule the future display of the tooltipN)
unscheduler	   afterrO   r(   rP   r   s    r   r^   OnHoverTooltipBase.schedule{   s4    ++11$2B2B26,,@r   c                 p    U R                   nSU l         U(       a  U R                  R                  U5        gg)z(cancel the future display of the tooltipN)rP   r	   after_cancel)r   after_ids     r   re   OnHoverTooltipBase.unschedule   s.    >>++H5 r   c                 d   >  U R                  5         [        TU ]  5         g! [         a     Nf = fr=   )re   r!   rN   r   r[   s    r   r   OnHoverTooltipBase.hidetip   s2    	OO 	  		s   " 
//)rP   rS   rU   rV   rO   )  r   )r@   rA   rB   rC   rD   r   r   rR   rT   r^   re   r   rE   __classcell__rW   s   @r   rH   rH   R   s0    IJ$@6 r   rH   c                   :   ^  \ rS rSrSr  SU 4S jjrS rSrU =r$ )Hovertip   zAA tooltip that pops up when a mouse hovers over an anchor widget.c                 D   > [         TU ]  XS9  X l        X@l        XPl        g)aF  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.
rO   N)rN   r   text
foreground
background)r   r	   rv   rO   rw   rx   rW   s         r   r   Hovertip.__init__   s$     	@	$$r   c           
          [        U R                  U R                  [        [        SU R
                  U R                  S9nUR                  5         g )Nr   )rv   justifyreliefborderwidthrw   rx   )Labelr
   rv   LEFTSOLIDrw   rx   pack)r   labels     r   r#   Hovertip.showcontents   s8    dnn499d#!"&//dooO 	

r   )rx   rw   rv   )rn   z#000000z#ffffe0)	r@   rA   rB   rC   rD   r   r#   rE   ro   rp   s   @r   rr   rr      s    G8<2;%  r   rr   c                    [        U 5      nUR                  S5        [        [        U R	                  5       R                  S5      SS  5      u  p#UR	                  SX#S-   4-  5        [        USS9nUR                  5         [        USS9nUR                  5         [        US	S
S9  [        USS9nUR                  5         [        USS S9  g )NzTest tooltip+r   r+      zPlace your mouse over buttons)rv   z"Button 1 -- 1/2 second hover delayz!This is tooltip text for button1.i  ru   zButton 2 -- no hover delayz!This is tooltip
text for button2.)
r   titlemapintgeometrysplitr~   r   Buttonrr   )parenttopr0   r1   r   button1button2s          r   _tooltipr      s    
6
CIInsFOO%++C045DALLQCL()#;<E	JJLSCDGLLNW9sKS;<GLLNW:Mr   __main__)mainzidlelib.idle_test.test_tooltip   F)	verbosityexit)runN)rD   tkinterr   rH   rr   r   r@   unittestr   idlelib.idle_test.htestr   rF   r   r   <module>r      se    E EP< <~! 2N z	)QUC+M r   