[0@szdZddlTddljZddlZddlZGdddeZe dkrvddl m Z e endS)z6 Dialog for building Tkinter accelerator key bindings )*Nc@seZdZdddZddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ dddZ dddZddZdS) GetKeysDialogFcCstj|||jdd|jdtdt|j||j||j|jd|j ||_ ||_ ||_ d|_ t||_|jjd|jg|_x:|jD]/}t|}|jd|jj|qWd|_|j|j|j|j|jd|j|jd |jd |j|s|jd |j d nd f|j!|j"d S) a3 action - string, the name of the virtual event these keys will be mapped to currentKeys - list, a list of all key sequence lists currently mapped to virtual events, for overlap checking _htest - bool, change box location when running htest borderwidthheightwidthZWM_DELETE_WINDOWFz+%d+%dN)#Toplevel__init__Z configureZ resizableZFALSEtitleZ transientZgrab_setZprotocolCancelparentactioncurrentKeySequencesresultZ StringVar keyStringsetSetModifiersForPlatform modifier_vars modifiersappendadvanced CreateWidgetsLoadFinalKeyListZwithdrawZupdate_idletasksZgeometryZ winfo_rootxZ winfo_widthZwinfo_reqwidthZ winfo_rootyZ winfo_heightZwinfo_reqheightZ deiconifyZ wait_window)selfrr rrZ_htestmodifiervariabler./usr/lib/python3.4/idlelib/keybindingDialog.pyr s@                  0 zGetKeysDialog.__init__c CsZt|dddt}|jdtdtdtt|}|jdtdtt|ddd d d |j |_ |j j d d dd ddddt|ddd d d |j |_ |j j d d ddddddt||_t||_t||_t||_|jj d d dd dtdddd|jj d d dd dtdddd|jj|jj d ddd dtdd|jj d ddd dtdd|jjt|d |jdd|_|jj d ddd dtddddt|jdd|jd}|jdtt|jdtd|jdtdd}|jdddddti|_d }xt|j|j D]\}}|j!j"||}t#|jd |j$d|d|d|d d!} | j d d d|dddt| |j|<|d7}qWt|jdtdd"d#d$d%d&d'} | j d ddd d(d)dddtt%|jd d*d+d,d-t&|_'|j'j(d.|j)|j'j d d dd)d/d)dt*t+|jd0t,d |j'j-} |j'j.d1| j/| j d d ddd/d)dt*t|jdd2d |j0|_1|j1j d ddd d(d)t|jdtdd3|jd4d5} | jdtt2|jd|j|_3|j3jdtt|jdtdd6d7d8d9d:d;d<} | j d d dd dtdS)=Nrr ZreliefZsideexpandZfilltextOKrZcommandrowrcolumnZpadxrZpadyrZstickyzAdvanced Key Binding Entry >>ZstickzNew keys for 'z' :ZanchorZjustifyZ textvariableZipadxZipadyrZonvalueZoffvaluerz!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.)Z columnspanr Z selectmodezZrowspanZorientZyscrollcommandz Clear KeyszEnter new binding(s) for 'z' : z2(These bindings will not be checked for validity!)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., .)4ZFrameZSUNKENZpackZTOPZTRUEZBOTHZBOTTOMXZButtonr#ZbuttonOKZgridrZ buttonCancelframeKeySeqBasicframeKeySeqAdvancedframeControlsBasicframeHelpAdvancedZNSEWlift ToggleLevel buttonLevelZEWZLabelrWZLEFTrZGROOVEZmodifier_checkbuttonsziprrmodifier_labelgetZ CheckbuttonBuildKeyStringZListboxZSINGLE listKeysFinalZbindFinalKeySelectedZNSZ ScrollbarZVERTICALyviewconfigr ClearKeySeqZ buttonClearZEntryentryKeysAdvanced)rZ frameMainZ frameButtonsZlabelTitleBasicZlabelKeysBasicr&rrZlabelZcheckZ labelFnAdviceZscrollKeysFinalZlabelTitleAdvancedZlabelHelpAdvancedrrr r5s %%++ %%  +  "  "  ( %"    zGetKeysDialog.CreateWidgetscCsMtjdkr'ddddg|_ndddg|_idd6|_dS) aUDetermine 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. darwinShiftZControlZOptionZCommandZAltZCtrlN)sysplatformrr5)rrrr rsz%GetKeysDialog.SetModifiersForPlatformcCs|jjddddkrr|j|jjdd|jj|jj|jjd|_ n@|j|jjdd|j j|j jd|_ dS)Nr"r$ZAdvancedz<< Basic Key Binding EntryTzAdvanced Key Binding Entry >>F) r2Zcgetr<r;r-r0r/r=Z focus_setrr,r.)rrrr r1s"        zGetKeysDialog.ToggleLevelcCs|jdS)N)r7)reventrrr r9szGetKeysDialog.FinalKeySelectedcCso|j}}|jjt}|rJ|j||}|j|n|jjddj|ddS)N<->) GetModifiersr8r6ANCHOR TranslateKeyrrrjoin)rZkeyListrfinalKeyrrr r7s zGetKeysDialog.BuildKeyStringcCs'dd|jD}dd|DS)NcSsg|]}|jqSr)r6).0rrrr s z.GetKeysDialog.GetModifiers..cSsg|]}|r|qSrr)rKmodrrr rLs )r)rZmodListrrr rFszGetKeysDialog.GetModifierscCs[|jjdt|jjtdx|jD]}|jdq0W|jjddS)Nrz0.0r)r8Z select_clearENDr:ZMOVETOrrr)rrrrr r<s zGetKeysDialog.ClearKeySeqc Csd|_ttjtj|_td |_d|_d|_d|_ |j|j|j|j|j|j }|j j t |dS)NF1F2F4F5F6F7F8F9F10F11F12z~!@#%^&*()_-+={}[]|;:,.<>/?TabSpaceReturn BackSpaceDeleteInsertHomeEndPage Up Page Down Left Arrow Right ArrowUp Arrow Down Arrow) rOrPrPrQrRrSrTrUrVrWrXrY)rZr[r\)r]r^r_)r`rarbrcrdrerfrg) functionKeystuplestringascii_lowercaseZdigitsZ alphanumKeysZpunctuationKeysZwhitespaceKeysZeditKeysmoveKeysr8insertrN)rkeysrrr rs    ,zGetKeysDialog.LoadFinalKeyListcCsLi#dd6dd6dd6dd6d d 6d d 6d d6dd6dd6dd6dd6dd6dd6dd6dd6dd 6d!d"6d#d$6d%d&6d'd(6d)d*6d+d,6d-d.6d/d06d1d26d3d46d5d66d7d86d9d:6d;d<6d=d>6d?d@6dAdB6dCdD6dEdE6}||kr||}ndF|kr>|tjkr>|j}ndG|}|S)Hz2Translate from keycap symbol to the Tkinter keysymZspacer[Z asciitilde~Zexclam!at@Z numbersign#Zpercent%Z asciicircum^Z ampersand&ZasteriskrZ parenleft(Z parenright)Z underscore_ZminusrDZplus+Zequal=Z braceleft{Z braceright}Z bracketleft[Z bracketright]Zbar|Z semicolon;Zcolon:Zcomma,Zperiod.ZlessrCZgreaterrEZslash/Zquestion?ZPriorzPage UpZNextz Page DownZLeftz Left ArrowZRightz Right ArrowZUpzUp ArrowZDownz Down ArrowrZr?zKey-)rjrkupper)rkeyrZ translateDictrrr rHs  #   zGetKeysDialog.TranslateKeyNcCs8|js|jr4|jj|_|jndS)N)rKeysOKrr6rdestroy)rrBrrr r#szGetKeysDialog.OKcCsd|_|jdS)Nr)rr)rrBrrr rs zGetKeysDialog.CancelcCsj|jj}|j|jjt}|j}|j}d}d}|sttjd|d|ddn|j dstjd|d|ddn| r||j |j krtjd|d|dd n|d gkr,||j |j dkr,d }tjd|d|d|n:||j kr`d}tjd|d|d|nd}|S)zValidity check on user's 'basic' keybinding selection. Doesn't check the string produced by the advanced dialog because 'modifiers' isn't set. FzKey Sequence Errorr rmessagezNo keys specified.rEzMissing the final KeyzNo modifier key(s) specified.r?rZr[zBThe shift modifier by itself may not be used with this key symbol.z'This key combination is already in use.T)zTabzSpace) rr6stripr8rGrFsplit tkMessageBoxZ showerrorendswithrhrlr)rrnrJrZ keySequenceZkeysOKr msgrrr rs6      zGetKeysDialog.KeysOK)__name__ __module__ __qualname__r rrr1r9r7rFr<rrHr#rrrrrr r s + O        r__main__)run) __doc__ZtkinterZtkinter.messageboxZ messageboxrrjr@r rrZidlelib.idle_test.htestrrrrr s