3 2a`4@szddlTddlmZddlmZddlZddlZGdddeZedkrvddl m Z e d d d d dd l m Z e edS))*) Scrollbar) messageboxNc@seZdZdZdddddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZd#ddZd$ddZdd Zd!d"ZdS)% GetKeysDialogzKey Sequence ErrorF)_htest_utestc CsNtj|||j|jdd|jttd|j||j||j|j d|j ||_ ||_ ||_ d|_t||_|jjd|jg|_x,|jD]"}t|}|jd|jj|qWd|_|j|j|j|jd|j|jd|jd|j|s(|jd|j dnd f|sJ|j!|j"dS) N) borderwidth)heightwidthZWM_DELETE_WINDOWFz+%d+%d)#Toplevel__init__ZwithdrawZ configureZ resizableZFALSEtitleZ transientZgrab_setZprotocolCancelparentactioncurrentKeySequencesresultZ StringVar keyStringsetSetModifiersForPlatform modifier_vars modifiersappendadvanced CreateWidgetsLoadFinalKeyListZupdate_idletasksZgeometryZ winfo_rootxZ winfo_widthZwinfo_reqwidthZ winfo_rootyZ winfo_heightZwinfo_reqheightZ deiconifyZ wait_window) selfrrrrrrmodifiervariabler#//opt/alt/python36/lib64/python3.6/config_key.pyrsB        *zGetKeysDialog.__init__cOstj||dS)N)r showerror)r argskwargsr#r#r$r%>szGetKeysDialog.showerrorc Cst|dtd}|jtttdt|}|jttdt|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|jjt||jdd|_|jj ddtd d dt|jd|jdd}|jtdt|jt|jtdd}|jd d tdi|_d}xft|j|j D]T\}}|j!j"||}t#|j|j$|||dd} | j d|dtd| |j|<|d 7}qWt|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!} | jtdt2|j|jd1|_3|j3jtd2t|jtdEd!} | j ddtd:dS)FNr )r relief)sideexpandfill)r)r+OK)textr commandrr)rowcolumnpadxpadyr)r0r1stickyr2r3)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 zin 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 zSelect 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 zSelect 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.)zKey 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. aKey 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 aKey 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., .)4ZFrameZSUNKENpackZTOPZTRUEZBOTHZBOTTOMXZButtonr,ZbuttonOKZgridrZ buttonCancelframeKeySeqBasicframeKeySeqAdvancedframeControlsBasicframeHelpAdvancedZNSEWlift ToggleLevel buttonLevelZEWZLabelrWZLEFTrZGROOVEZmodifier_checkbuttonsziprrmodifier_labelgetZ CheckbuttonBuildKeyStringZListboxZSINGLE listKeysFinalbindFinalKeySelectedZNSrZVERTICALyviewconfigr ClearKeySeqZ buttonClearZEntryentryKeysAdvanced)r Z frameMainZ frameButtonsZlabelTitleBasicZlabelKeysBasicr1r!r"ZlabelZcheckZ labelFnAdviceZscrollKeysFinalZlabelTitleAdvancedZlabelHelpAdvancedr#r#r$rBs                zGetKeysDialog.CreateWidgetscCs4tjdkrddddg|_n dddg|_ddi|_dS)NdarwinShiftZControlZOptionZCommandZAltZCtrl)sysplatformrrG)r r#r#r$rs  z%GetKeysDialog.SetModifiersForPlatformcCs|jjddddkrT|j|jjdd|jj|jj|jjd|_ n0|j|jjdd|j j|j jd|_ dS) Nr.r-ZAdvancedz<< Basic Key Binding Entry)r.TzAdvanced Key Binding Entry >>F) rDZcgetrOrNr?rBrArPZ focus_setrr>r@)r r#r#r$rCs     zGetKeysDialog.ToggleLevelcCs |jdS)N)rI)r eventr#r#r$rLszGetKeysDialog.FinalKeySelectedcCsP|j}}|jjt}|r2|j||}|j||jjddj|ddS)N<->) GetModifiersrJrHANCHOR TranslateKeyrrrjoin)r ZkeyListrfinalKeyr#r#r$rIs     zGetKeysDialog.BuildKeyStringcCsdd|jD}dd|DS)NcSsg|] }|jqSr#)rH).0r"r#r#r$ sz.GetKeysDialog.GetModifiers..cSsg|] }|r|qSr#r#)r^modr#r#r$r_s)r)r ZmodListr#r#r$rYszGetKeysDialog.GetModifierscCsF|jjdt|jjtdx|jD]}|jdq$W|jjddS)Nrz0.0r )rJZ select_clearENDrMZMOVETOrrr)r r"r#r#r$rOs  zGetKeysDialog.ClearKeySeqc Csnd|_ttjtj|_td |_d|_d|_d|_ |j|j|j|j|j|j }|j j t f|dS) NF1F2F3F4F5F6F7F8F9F10F11F12z~!@#%^&*()_-+={}[]|;:,.<>/?TabSpaceReturn BackSpaceDeleteInsertHomeEndPage Up Page Down Left Arrow Right ArrowUp Arrow Down Arrow) rbrcrdrerfrgrhrirjrkrlrm)rnrorp)rqrrrs)rtrurvrwrxryrzr{) functionKeystuplestringascii_lowercasedigitsZ alphanumKeysZpunctuationKeysZwhitespaceKeysZeditKeysmoveKeysrJinsertra)r keysr#r#r$rs $zGetKeysDialog.LoadFinalKeyListc$Csddddddddd d d d d ddddddddddddddddddd d!d"d#d$#}||kr\||}d%|krv|tjkrv|j}d&|}|S)'NZspaceZ asciitildeZexclamZatZ numbersignpercentZ 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~rupper)r keyrZ translateDictr#r#r$r[s   zGetKeysDialog.TranslateKeyNcCs\|jjj}|s(|j|j|dddS|js8|j|rH|j|rH||_|j |j dS)NzNo key specified.)rrmessage) rrHstripr%keyerror_titlerKeysOKbind_okr grab_releasedestroy)r rUrr#r#r$r,s zGetKeysDialog.OKcCsd|_|j|jdS)Nr )rrr)r rUr#r#r$rszGetKeysDialog.CancelcCs|jjt}|j}d}|j}dd|jD}|jdsJ|j||ddn~| rr||j|j krr|j||ddnV|d gkr||j|j dkrd }|j|||dn"||krd }|j|||dnd}|S)NFcSsg|]}|D]}|q qSr#r#)r^Zkeylistrr#r#r$r_sz(GetKeysDialog.KeysOK..rXzMissing the final Key)rrzNo modifier key(s) specified.)rrrrRrnrozBThe shift modifier by itself may not be used with this key symbol.z'This key combination is already in use.T)rnro) rJrHrZrYrrendswithr%r|r)r rr]rZkeysOKrZ key_sequencesmsgr#r#r$rs,     zGetKeysDialog.KeysOKcCsby|j|dd}Wn8tk rL}z|j|j|d|ddSd}~XnX|j||dSdS)NcSsdS)Nr#r#r#r#r$sz'GetKeysDialog.bind_ok..z2The entered key sequence is not accepted. Error: )rrrFT)rKZTclErrorr%rZunbind)r rZbindingerrr#r#r$rs zGetKeysDialog.bind_ok)N)N)__name__ __module__ __qualname__rrr%rrrCrLrIrYrOrr[r,rrrr#r#r#r$r s -O !r__main__)mainz!idlelib.idle_test.test_config_keyr F) verbosityexit)run) ZtkinterZ tkinter.ttkrrr~rSrrrZunittestrZidlelib.idle_test.htestrr#r#r#r$s