\ddZddlmZmZmZmZddlmZdZdZ dZ dZ dZ d Z Gd d eZd Zed kr'ddlmZedddddlmZeedSdS)zvA call-tip window class for Tkinter/IDLE. After tooltip.py, which uses ideas gleaned from PySol. Used by calltip.py. )LabelLEFTSOLIDTclError) TooltipBasez<>)z z z<>)z zdcalltipwindowregion_rightcfeZdZdZfdZdZfdZfdZdZd dZ d Z fd Z d Z d Z xZS) CalltipWindowz+A call-tip widget for tkinter text widgets.ct|dx|_|_dx|_x|_|_dx|_|_d|_ dS)z}Create a call-tip; shown by showtip(). text_widget: a Text widget with code for which call-tips are desired N) super__init__labeltext parenlineparencollastlinehideid checkhideidcheckhide_after_id)self text_widget __class__s "..\python\lib\idlelib\calltip_w.pyrzCalltipWindow.__init__s] %%%!%% TY9===)-- d&"&ct|jddd}||jkr|j|jf}n|df}|jd|z}|s1t|jd}d|d<d|d<|ddz|d|dzfS)z$Choose the position of the call-tip.insert.rz%d.%d)int anchor_widgetindexsplitrrbboxlist)rcurline anchor_indexboxs r get_positionzCalltipWindow.get_position#sd(..x88>>sCCAFGG dn $ $ NDM:LL#Q>sCCAFGG dm # # F  x((( !!!!!rcx||_|js|jsdS|jt|t t |j|d\|_ |_ t | dS)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#mark_set MARK_RIGHTmapr"r$r%rrr showtip _bind_events)rr parenleft parenrightrs rr4zCalltipWindow.showtip;s >   F ##J ;;;(+ #)))44::3??)A)A%   rc t|j|jtddtd|jd|_|jdS)zCreate the call-tip widget.z#ffffd0blackr font)rjustify background foregroundrelief borderwidthr:N)rr0rrrr#rpack)rs r showcontentszCalltipWindow.showcontentsPsQ4> 4&/G"'Q $ 26 :<<<  rNc|jsdStt|jdd\}}||jks7||jkr ||jks!|jddtr| dS| |j |j |j |jt|j|_ dS)z4Handle CHECK_HIDE_EVENT: call hidetip or reschedule.Nrr>break)r0r3r"r#r$r%rrcomparer2hidetipr.r after_cancelafterCHECKHIDE_TIMEcheckhide_event)reventr(curcols rrJzCalltipWindow.checkhide_eventXs~ 4c4#5#;#;H#E#E#K#KC#P#PQQ T^ # # t~ % %&DM*A*A   % %hZ @ @+B LLNNN7   " .   + +D,C D D D   $ $^T5I J J trc@|jsdS|dS)z%Handle HIDE_EVENT by calling hidetip.NrD)r0rF)rrKs r hide_eventzCalltipWindow.hide_eventss#~ 4 wrc|jsdS |jn#t$rYnwxYwd|_dx|_x|_|_ |jtn#t$rYnwxYw | n#ttf$rYnwxYwt dS)zHide the call-tip.N)r0rdestroyrrrrr# mark_unsetr2_unbind_events ValueErrorr rF)rrs rrFzCalltipWindow.hidetip{s~  F  J       D  9===    ) )* 5 5 5 5    D      ! ! ! !*%    D  s0& 33A33 B?BBB-,B-c|jt|j|_t D]"}|jt|#|jt|j|jt|j |_ tD]"}|jt|#dS)zBind event handlers.N) r#bindCHECKHIDE_EVENTrJrCHECKHIDE_SEQUENCES event_addrHrI HIDE_EVENTrNrHIDE_SEQUENCESrseqs rr5zCalltipWindow._bind_eventss-22?373GII& ? ?C   ( (# > > > >   1EFFF(--j.2o?? ! : :C   ( (S 9 9 9 9 : :rc^tD]"}|jt|#|jt|jd|_t D]"}|jt|#|jt|jd|_dS)zUnbind event handlers.N) rWr# event_deleterVunbindrrZrYrr[s rrRzCalltipWindow._unbind_eventss& B BC   + +OS A A A A !!/43CDDD! = =C   + +J < < < < !!*dk::: rN)__name__ __module__ __qualname____doc__rr+r.r4rArJrNrFr5rR __classcell__)rs@rr r s55 ' ' ' ' ' + + +"""""*62 : : :       rr c ddlm}m}m}m}||}|dt t| ddd\}}|d|dz|dzfz||}| ||d | d d | t| fd } fd } |dd|dd|d| |d| |dS)Nr)ToplevelTextrBOTHzTest call-tips+r z 250x100+%d+%d)sidefillexpandrz string.splitc6ddddS)Nz(s='Hello world')rend)r4rKcalltips r calltip_showz%_calltip_window..calltip_shows +Xu=====rc0dSr`)rFrrs r calltip_hidez%_calltip_window..calltip_hidesrz<>(z<>))tkinterrgrhrrititler3r"geometryr%r@rupdater rXrU focus_set) parentrgrhrritopxyrrtrvrss @r_calltip_windowrs222222222222 (6  CII sFOO%%++C004 5 5DAqLLAGQW#55666 499DII4d1I---KK.)))JJLLLD!!G>>>>>NN%s+++NN%s+++II ,///II ,///NNr__main__)mainz idlelib.idle_test.test_calltip_wrF) verbosityexit)runN)rdryrrrridlelib.tooltiprrYrZrVrWrIr2r rraunittestridlelib.idle_test.htestrrrrs 100000000000'''''' % //9 ( VVVVVKVVVr0 zD +quEEEE++++++C r