B „ f�8ã@sêdZddlmZmZmZmZddlmZmZm Z m Z m Z m Z ddlm Z ddlZddlZdZeejejƒZedƒZdZd Zd ZeeeeeeZd d „ZGd d„deƒZedkræddlmZedddd�ddlm Z e eƒdS)z6 Dialog for building Tkinter accelerator key bindings é)ÚToplevelÚListboxÚ StringVarÚTclError)ÚFrameÚButtonÚ CheckbuttonÚEntryÚLabelÚ Scrollbar)Ú messageboxN) ZF1ZF2ZF3ZF4ZF5ZF6ZF7ZF8ZF9ZF10ZF11ZF12z~!@#%^&*()_-+={}[]|;:,.<>/?)ÚTabÚSpaceZReturn)Z BackSpaceZDeleteZInsert)ZHomeZEndzPage Upz Page Downz Left Arrowz Right ArrowzUp Arrowz Down Arrowc$Cs|ddddddddd d d d d ddddddddddddddddddd d!d"d#d$œ#}| ||¡}d%|krr|tjkrr| ¡}d&|›�S)'z3Translate from keycap symbol to the Tkinter keysym.ZspaceZ asciitildeZexclamZatZ numbersignZpercentZ asciicircumZ ampersandZasteriskZ parenleftZ parenrightZ underscoreZminusZplusZequalZ braceleftZ bracerightZ bracketleftZ bracketrightZbarZ semicolonZcolonZcommaZperiodZlessZgreaterZslashZquestionZPriorZNextZLeftZRightZUpZDownr )#rú~ú!ú@ú#ú%ú^ú&Ú*ú(ú)Ú_ú-ú+ú=ú{ú}ú[ú]ú|ú;ú:ú,Ú.ú<ú>ú/ú?zPage Upz Page Downz Left Arrowz Right ArrowzUp Arrowz Down Arrowr ÚShiftzKey-)ÚgetÚstringÚascii_lowercaseÚupper)ÚkeyÚ modifiersÚmapping©r2ú7/opt/alt/python37/lib64/python3.7/idlelib/config_key.pyÚ translate_keys   r4c@s†eZdZdZdddœdd„Zdd„Zdd „Zd d „Zd d „Zddd„Z dd„Z dd„Z dd„Z d dd„Z d!dd„Zdd„Zdd„ZdS)"Ú GetKeysDialogzKey Sequence ErrorF)Ú_htestÚ_utestc CsFt ||¡| ¡|jdd�|jddd�| |¡| |¡| ¡| d|j ¡||_ ||_ ||_ d|_ t|ƒ|_|j d¡| ¡g|_x,|jD]"}t|ƒ}| d¡|j |¡qœWd|_| ¡| ¡| d| ¡| ¡d| ¡d| ¡|�s | ¡d| ¡dnd f¡|�sB| ¡|  ¡d S) aÛ parent - parent of this dialog title - string which is the title of the popup dialog action - string, the name of the virtual event these keys will be mapped to current_key_sequences - list, a list of all key sequence lists currently mapped to virtual events, for overlap checking _htest - bool, change box location when running htest _utest - bool, do not wait when running unittest é)Ú borderwidthF)ÚheightÚwidthZWM_DELETE_WINDOWÚz+%d+%déé–N)!rÚ__init__ZwithdrawZ configureZ resizableÚtitleZ transientZgrab_setZprotocolÚcancelÚparentÚactionÚcurrent_key_sequencesÚresultrÚ key_stringÚsetÚset_modifiers_for_platformÚ modifier_varsr0ÚappendÚadvancedÚcreate_widgetsZupdate_idletasksZgeometryZ winfo_rootxZ winfo_widthZwinfo_reqwidthZ winfo_rootyZ winfo_heightZwinfo_reqheightZ deiconifyZ wait_window) ÚselfrBr@rCrDr6r7ÚmodifierÚvariabler2r2r3r?0s@        *zGetKeysDialog.__init__cOstj||ŽdS)N)r Ú showerror)rMÚargsÚkwargsr2r2r3rP`szGetKeysDialog.showerrorc Cs0t|ddd�|_}|jdddd�t|ƒ}|jdd d �t|d d |jd �|_|jjddddd�t|dd |jd �|_|jjddddd�t|dd�|_ |j jdddddd�t |j d|j ›d�d�}|jdd�t |j d|j ddd�}|jddd d�t|ƒ|_ |j jddddd �i|_d}xft|j|jƒD]T\}}|j ||¡}t|j |j|||d!d"�} | jd|ddd#�| |j|<|d7}�q0Wt |j dd$d%�} | jddd&ddd'�t|j d(d)d*d+�|_|jjdBtžŽ|j d-|j¡|jjdd&d&d.d/�t|j d0|jjd1�} |jj| jd2�| jddd&d.d/�t|j d3|j d4�|_!|j!jddd&d5�t|d6d�|_"|j"jdddddd�t |j"dd7|j ›d8�d9d%�} | jdd�t#|j"|j d:�|_$|j$jd d;�t|ƒ|_%|j%jddddd �t |j%ddd?�|_'|j'jddd@dddA�| &¡dS)CNr=Zsunken)r9ÚreliefÚtopTZboth)ÚsideÚexpandÚfillZbottomÚx)rUrWZOKé)Útextr;Úcommandrr8)ÚrowÚcolumnÚpadxÚpadyZCanceléZ keyseq_basic)ÚnameZnsew)r\r]Ústickyr^r_zNew keys for 'z' :)rZÚw)ÚanchorÚleftZgroove)ÚjustifyÚ textvariablerSr9)ZipadxZipadyrW)r\r]rbr^r<)r[rZrOZonvalueZoffvalue)r\r]r^rbz¸Select the desired modifier keys above, and the final key from the list on the right. Use upper case Symbols when using the Shift modifier. (Letters will be converted automatically.))rfrZé)r\r]Ú columnspanr^rbéé Zsingle)r;r:Z selectmodeÚendzÚns)r\r]ZrowspanrbZvertical)Zorientr[)Zyscrollcommandz Clear Keys)rZr[)r\r]riZkeyseq_advancedzEnter new binding(s) for 'z' : z2(These bindings will not be checked for validity!))rg)rWaÁKey bindings are specified using Tkinter keysyms as in these samples: , , , , , . Upper case is used when the Shift modifier is present! 'Emacs style' multi-keystroke bindings are specified as follows: , where the first key is the 'do-nothing' keybinding. Multiple separate bindings for one action should be separated by a space, eg., .)r\r]rbz<< Basic Key Binding Entry)r[rZZew)r\r]Zstickr^r_)rl)(rÚframeZpackrÚokZ button_okZgridrAZ button_cancelÚframe_keyseq_basicr rCrFÚframe_controls_basicZmodifier_checkbuttonsÚzipr0rIÚmodifier_labelr+rÚbuild_key_stringrÚlist_keys_finalÚinsertÚAVAILABLE_KEYSÚbindÚfinal_key_selectedr ÚyviewÚconfigrGÚ clear_key_seqZ button_clearÚframe_keyseq_advancedr Ú advanced_keysÚframe_help_advancedÚ toggle_levelÚ button_level)rMrnZ frame_buttonsZ basic_titleZ basic_keysr]rNrOZlabelZcheckZ help_basicZscroll_keys_finalZadvanced_titleZ help_advancedr2r2r3rLdsˆ                 zGetKeysDialog.create_widgetscCs4tjdkrddddg|_n dddg|_ddi|_dS) aVDetermine list of names of key modifiers for this platform. The names are used to build Tk bindings -- it doesn't matter if the keyboard has these keys; it matters if Tk understands them. The order is also important: key binding equality depends on it, so config-keys.def must use the same ordering. Údarwinr*ZControlZOptionZCommandZAltZCtrlN)ÚsysÚplatformr0rs)rMr2r2r3rHÊs  z(GetKeysDialog.set_modifiers_for_platformcCs‚|j d¡ d¡rN| ¡|jjdd�|j ¡|j ¡|j  ¡d|_ n0| ¡|jjdd�|j  ¡|j  ¡d|_ dS) z'Toggle between basic and advanced keys.rZZAdvancedz<< Basic Key Binding Entry)rZTzAdvanced Key Binding Entry >>FN) r�ZcgetÚ startswithr|r{r}Zliftrr~Z focus_setrKrprq)rMr2r2r3r€Øs     zGetKeysDialog.toggle_levelNcCs | ¡dS)z3Handler for clicking on key in basic settings list.N)rt)rMÚeventr2r2r3ryèsz GetKeysDialog.final_key_selectedcCsN| ¡}}|j d¡}|r0t||ƒ}| |¡|j dd |¡›d�¡dS)z2Create formatted string of modifiers plus the key.rdr&rr'N)Ú get_modifiersrur+r4rJrFrGÚjoin)rMÚkeylistr0Ú final_keyr2r2r3rtìs     zGetKeysDialog.build_key_stringcCsdd„|jDƒ}dd„|DƒS)z9Return ordered list of modifiers that have been selected.cSsg|] }| ¡‘qSr2)r+)Ú.0rOr2r2r3ú ÷sz/GetKeysDialog.get_modifiers..cSsg|] }|r|‘qSr2r2)r‹Úmodr2r2r3rŒøs)rI)rMZmod_listr2r2r3r‡õszGetKeysDialog.get_modifierscCsF|j dd¡|j dd¡x|jD]}| d¡q$W|j d¡dS)z#Clear modifiers and keys selection.rrlZmovetoz0.0r<N)ruZ select_clearrzrIrGrF)rMrOr2r2r3r|ús  zGetKeysDialog.clear_key_seqcCs\|j ¡ ¡}|s(|j|j|dd�dS|js8| |¡rH| |¡rH||_|  ¡|  ¡dS)NzNo key specified.)r@rBÚmessage) rFr+ÚstriprPÚkeyerror_titlerKÚkeys_okÚbind_okrEÚ grab_releaseÚdestroy)rMr†Úkeysr2r2r3ros zGetKeysDialog.okcCsd|_| ¡| ¡dS)Nr<)rEr“r”)rMr†r2r2r3rA szGetKeysDialog.cancelcCs¾|j d¡}| ¡}|j}dd„|jDƒ}| d¡sF|j||dd�nt|sh|ttkrh|j||dd�nR|d gkr˜|ttd kr˜d }|j|||d�n"||kr¶d }|j|||d�nd SdS)z¨Validity check on user's 'basic' keybinding selection. Doesn't check the string produced by the advanced dialog because 'modifiers' isn't set. rdcSsg|]}|D]}|‘q qSr2r2)r‹r‰r/r2r2r3rŒsz)GetKeysDialog.keys_ok..r'zMissing the final Key)rBrŽzNo modifier key(s) specified.)r@rBrŽr*)r rzBThe shift modifier by itself may not be used with this key symbol.z'This key combination is already in use.TF) rur+r‡r�rDÚendswithrPÚ FUNCTION_KEYSÚ MOVE_KEYS)rMr•rŠr0r@Z key_sequencesÚmsgr2r2r3r‘s*      zGetKeysDialog.keys_okc Csdy| |dd„¡}Wn:tk rN}z|j|j|d|›�d�dSd}~XYnX| ||¡dSdS)z:Return True if Tcl accepts the new keys else show message.cSsdS)Nr2r2r2r2r3Ú4óz'GetKeysDialog.bind_ok..z2The entered key sequence is not accepted. Error: )r@rBrŽFNT)rxrrPr�Zunbind)rMr•ZbindingÚerrr2r2r3r’1s zGetKeysDialog.bind_ok)N)N)N)Ú__name__Ú __module__Ú __qualname__r�r?rPrLrHr€ryrtr‡r|rorAr‘r’r2r2r2r3r5+s/f   r5Ú__main__)Úmainz!idlelib.idle_test.test_config_keyr=F)Ú verbosityÚexit)Úrun)!Ú__doc__ZtkinterrrrrZ tkinter.ttkrrrr r r r r,rƒr—Útupler-ZdigitsZ ALPHANUM_KEYSZPUNCTUATION_KEYSZWHITESPACE_KEYSZ EDIT_KEYSr˜rwr4r5r�Zunittestr¡Zidlelib.idle_test.htestr¤r2r2r2r3Ús*