3 Õì2a`4ã@szddlTddlmZddlmZddlZddlZGdd„deƒZedkrvddl m Z e d d d d �dd l m Z e eƒdS)é)Ú*)Ú Scrollbar)Ú messageboxNc@s”eZdZdZdddœdd„Zdd„Zdd „Zd d „Zd d „Zdd„Z dd„Z dd„Z dd„Z dd„Z dd„Zd#dd„Zd$dd„Zdd „Zd!d"„ZdS)%Ú GetKeysDialogzKey Sequence ErrorF)Ú_htestÚ_utestc CsNtj||ƒ|jƒ|jdd�|jttd�|j|ƒ|j|ƒ|jƒ|j d|j ƒ||_ ||_ ||_ d|_t|ƒ|_|jjdƒ|jƒg|_x,|jD]"}t|ƒ}|jdƒ|jj|ƒqœWd|_|jƒ|jƒ|jƒ|jd|jƒ|jƒd|jƒd|jƒ|�s(|jƒd|j ƒdnd fƒ|�sJ|j!ƒ|j"ƒdS) Né)Ú borderwidth)ÚheightÚwidthZWM_DELETE_WINDOWÚFz+%d+%déé–)#ÚToplevelÚ__init__ZwithdrawZ configureZ resizableZFALSEÚtitleZ transientZgrab_setZprotocolÚCancelÚparentÚactionÚcurrentKeySequencesÚresultZ StringVarÚ keyStringÚsetÚSetModifiersForPlatformÚ modifier_varsÚ modifiersÚappendÚadvancedÚ CreateWidgetsÚLoadFinalKeyListZupdate_idletasksZgeometryZ winfo_rootxZ winfo_widthZwinfo_reqwidthZ winfo_rootyZ winfo_heightZwinfo_reqheightZ deiconifyZ wait_window) ÚselfrrrrrrÚmodifierÚvariable©r#ú//opt/alt/python36/lib64/python3.6/config_key.pyrsB        *zGetKeysDialog.__init__cOstj||ŽdS)N)rÚ showerror)r ÚargsÚkwargsr#r#r$r%>szGetKeysDialog.showerrorc Cst|dtd�}|jtttd�t|ƒ}|jttd�t|dd|j d�|_ |j j ddd d d �t|d d|j d�|_ |j j dd d d d �t|ƒ|_t|ƒ|_t|ƒ|_t|ƒ|_|jj ddtd d d �|jj ddtd d d �|jjƒ|jj d dtd d�|jj d dtd d�|jjƒt||jdd�|_|jj ddtd d d�t|jd|jdd�}|jtd�t|jt|jtdd�}|jd d td�i|_d}xft|j|j ƒD]T\}}|j!j"||ƒ}t#|j|j$|||dd�} | j d|dtd�| |j|<|d 7}�q Wt|jtd?d!�} | j d dd"dtd#�t%|jd$d%t&d&�|_'|j'j(d'|j)ƒ|j'j dd"d"t*d(�t+|jt,|j'j-d)�} |j'j.| j/d*�| j dd d"t*d(�t|jd+|j0d,�|_1|j1j ddd"d-�t|jtd.|jd/d0d!�} | jtd�t2|j|jd1�|_3|j3jtd2�t|jtdEd!�} | j ddtd:�dS)FNr )r Úrelief)ÚsideÚexpandÚfill)r)r+ÚOKé)Útextr Úcommandrr)ÚrowÚcolumnÚpadxÚpadyré)r0r1Ústickyr2r3)r0r1r5r2zAdvanced Key Binding Entry >>)r/r.)r0r1Zstickr2r3zNew keys for 'z' :)r.)Zanchor)ÚjustifyÚ textvariabler(r )ZipadxZipadyr+r )r/r.r"ZonvalueZoffvalue)r0r1r2r5z!Select the desired modifier keys z"above, and the final key from the zlist on the right. z"Use upper case Symbols when using z&the Shift modifier. (Letters will be zconverted automatically.))r6r.é)r0r1Ú columnspanr2r5éé )r r Z selectmodez)r0r1Zrowspanr5)Zorientr/)Zyscrollcommandz Clear Keys)r.r/)r0r1r9zEnter new binding(s) for 'z' : z2(These bindings will not be checked for validity!))r7)r+z4Key bindings are specified using Tkinter keysyms as zŸin these samples: , , , , , . Upper case is used when the Shift modifier is present! z8'Emacs style' multi-keystroke bindings are specified as z5follows: , where the first key z!is the 'do-nothing' keybinding. z4Multiple separate bindings for one action should be z,separated by a space, eg., .)r0r1r5zCSelect the desired modifier keys above, and the final key from the zWSelect the desired modifier keys above, and the final key from the list on the right. zySelect the desired modifier keys above, and the final key from the list on the right. Use upper case Symbols when using zŸ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 z¸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.)zÓKey bindings are specified using Tkinter keysyms as in these samples: , , , , , . Upper case is used when the Shift modifier is present! a 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 a@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 aaKey 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. a•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 aÁ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., .)4ZFrameZSUNKENÚpackZTOPZTRUEZBOTHZBOTTOMÚXZButtonr,ZbuttonOKZgridrZ buttonCancelÚframeKeySeqBasicÚframeKeySeqAdvancedÚframeControlsBasicÚframeHelpAdvancedZNSEWÚliftÚ ToggleLevelÚ buttonLevelZEWZLabelrÚWZLEFTrZGROOVEZmodifier_checkbuttonsÚziprrÚmodifier_labelÚgetZ CheckbuttonÚBuildKeyStringZListboxZSINGLEÚ listKeysFinalÚbindÚFinalKeySelectedZNSrZVERTICALÚyviewÚconfigrÚ ClearKeySeqZ buttonClearZEntryÚentryKeysAdvanced)r Z frameMainZ frameButtonsZlabelTitleBasicZlabelKeysBasicr1r!r"ZlabelZcheckZ labelFnAdviceZscrollKeysFinalZlabelTitleAdvancedZlabelHelpAdvancedr#r#r$rBs‚                zGetKeysDialog.CreateWidgetscCs4tjdkrddddg|_n dddg|_ddi|_dS)NÚdarwinÚShiftZControlZOptionZCommandZAltZCtrl)ÚsysÚplatformrrG)r r#r#r$r‘s  z%GetKeysDialog.SetModifiersForPlatformcCsˆ|jjdƒdd…dkrT|jƒ|jjdd�|jjƒ|jjƒ|jjƒd|_ n0|jƒ|jjdd�|j jƒ|j jƒd|_ dS) Nr.r-ZAdvancedz<< Basic Key Binding Entry)r.TzAdvanced Key Binding Entry >>F) rDZcgetrOrNr?rBrArPZ focus_setrr>r@)r r#r#r$rCŸs     zGetKeysDialog.ToggleLevelcCs |jƒdS)N)rI)r Úeventr#r#r$rL®szGetKeysDialog.FinalKeySelectedcCsP|jƒ}}|jjtƒ}|r2|j||ƒ}|j|ƒ|jjddj|ƒdƒdS)Nú<ú-ú>) Ú GetModifiersrJrHÚANCHORÚ TranslateKeyrrrÚjoin)r ZkeyListrÚfinalKeyr#r#r$rI±s     zGetKeysDialog.BuildKeyStringcCsdd„|jDƒ}dd„|DƒS)NcSsg|] }|jƒ‘qSr#)rH)Ú.0r"r#r#r$ú ºsz.GetKeysDialog.GetModifiers..cSsg|] }|r|‘qSr#r#)r^Úmodr#r#r$r_»s)r)r ZmodListr#r#r$rY¹szGetKeysDialog.GetModifierscCsF|jjdtƒ|jjtdƒx|jD]}|jdƒq$W|jjdƒdS)Nrz0.0r )rJZ select_clearÚENDrMZMOVETOrrr)r r"r#r#r$rO½s  zGetKeysDialog.ClearKeySeqc Csnd|_ttjtjƒ|_td ƒ|_d|_d|_d|_ |j|j|j|j|j|j }|j j t f|žŽdS) NÚF1ÚF2ÚF3ÚF4ÚF5ÚF6ÚF7ÚF8ÚF9ÚF10ÚF11ÚF12z~!@#%^&*()_-+={}[]|;:,.<>/?ÚTabÚSpaceÚReturnÚ BackSpaceÚDeleteÚInsertÚHomeÚEndúPage Upú Page Downú Left Arrowú Right ArrowúUp Arrowú Down Arrow) rbrcrdrerfrgrhrirjrkrlrm)rnrorp)rqrrrs)rtrurvrwrxryrzr{) Ú functionKeysÚtupleÚstringÚascii_lowercaseÚdigitsZ alphanumKeysZpunctuationKeysZwhitespaceKeysZeditKeysÚmoveKeysrJÚinsertra)r Úkeysr#r#r$rÄs $zGetKeysDialog.LoadFinalKeyListc$Cs‚ddddddddd d d d d ddddddddddddddddddd d!d"d#d$œ#}||kr\||}d%|krv|tjkrv|jƒ}d&|}|S)'NZspaceZ asciitildeZexclamZatZ numbersignÚpercentZ asciicircumZ ampersandZasteriskZ parenleftZ parenrightZ underscoreZminusZplusZequalZ braceleftZ bracerightZ bracketleftZ bracketrightZbarZ semicolonZcolonZcommaZperiodZlessZgreaterZslashZquestionZPriorZNextZLeftZRightZUpZDownrn)#roú~ú!ú@ú#ú%ú^ú&rú(ú)Ú_rWú+ú=ú{ú}ú[ú]ú|ú;ú:ú,Ú.rVrXú/ú?zPage Upz Page Downz Left Arrowz Right ArrowzUp Arrowz Down ArrowrnrRzKey-)r~rÚupper)r ÚkeyrZ translateDictr#r#r$r[Ós   zGetKeysDialog.TranslateKeyNcCs\|jjƒjƒ}|s(|j|j|dd�dS|js8|j|ƒrH|j|ƒrH||_|j ƒ|j ƒdS)NzNo key specified.)rrÚmessage) rrHÚstripr%Úkeyerror_titlerÚKeysOKÚbind_okrÚ grab_releaseÚdestroy)r rUrƒr#r#r$r,æs zGetKeysDialog.OKcCsd|_|jƒ|jƒdS)Nr )rr£r¤)r rUr#r#r$rñszGetKeysDialog.CancelcCsÌ|jjtƒ}|jƒ}d}|j}dd„|jDƒ}|jdƒsJ|j||dd�n~| rr||j|j krr|j||dd�nV|d gkr¦||j|j dkr¦d }|j|||d�n"||krÄd }|j|||d�nd}|S)NFcSsg|]}|D]}|‘q qSr#r#)r^Zkeylistr�r#r#r$r_sz(GetKeysDialog.KeysOK..rXzMissing the final Key)rržzNo modifier key(s) specified.)rrržrRrnrozBThe shift modifier by itself may not be used with this key symbol.z'This key combination is already in use.T)rnro) rJrHrZrYr rÚendswithr%r|r�)r rƒr]rZkeysOKrZ key_sequencesÚmsgr#r#r$r¡ös,     zGetKeysDialog.KeysOKcCsby|j|dd„ƒ}Wn8tk rL}z|j|j|d|›�d�dSd}~XnX|j||ƒdSdS)NcSsdS)Nr#r#r#r#r$Úsz'GetKeysDialog.bind_ok..z2The entered key sequence is not accepted. Error: )rrržFT)rKZTclErrorr%r Zunbind)r rƒZbindingÚerrr#r#r$r¢s zGetKeysDialog.bind_ok)N)N)Ú__name__Ú __module__Ú __qualname__r rr%rrrCrLrIrYrOrr[r,rr¡r¢r#r#r#r$r s -O !rÚ__main__)Úmainz!idlelib.idle_test.test_config_keyr F)Ú verbosityÚexit)Úrun) ZtkinterZ tkinter.ttkrrr~rSrrr©Zunittestr­Zidlelib.idle_test.htestr°r#r#r#r$Ús