\d~;zdZddlmZmZmZmZddlmZmZm Z m Z m Z m Z ddlm Z ddlmZddlZddlZdZeejejzZedZd Zd Zd ZeezezezezezZd ZGd deZGddeZedkr'ddl m!Z!e!dddddl"m#Z#e#e$dSdS)z6 Dialog for building Tkinter accelerator key bindings )ToplevelListbox StringVarTclError)FrameButton CheckbuttonEntryLabel Scrollbar) messagebox) _setup_dialogN) F1F2F3F4F5F6F7F8F9F10F11F12z~!@#%^&*()_-+={}[]|;:,.<>/?)TabSpaceReturn) BackSpaceDeleteInsert)HomeEndPage Up Page Down Left Arrow Right ArrowUp Arrow Down Arrowc`iddddddddd d d d d ddddddddddddddddddd d!d"id#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdEi}|||}dF|vr"|tjvr|}dG|S)Hz3Translate from keycap symbol to the Tkinter keysym.rspace~ asciitilde!exclam@at# numbersign%percent^ asciicircum& ampersand*asterisk( parenleft) parenright_ underscore-minus+plus=equal{ braceleft} braceright[ bracketleft] bracketright|bar; semicolon:colon,comma.period<less>greater/slash?questionr#Priorr$Nextr%Leftr&Rightr'Upr(DownrShiftzKey-)getstringascii_lowercaseupper)key modifiersmappings #..\python\lib\idlelib\config_key.py translate_keyrps @ww @   @!( @,/ @69, @   @} @.1+ @   @  @.1 @  @"' @,/v @8;7 @  @ ! @ @  @ #> @ 47u @   @! @+.g @8;8 @  @I @(+7 @58  @ g @ +6 @  @"/w @ t @*6 @ @49 @ @G ++c3  C)v'= = =iikk #<<cfeZdZdZfdZdZdZdZdZddZ d Z d Z d Z d Z d ZdZxZS) GetKeysFramezKey Sequence Errorct|d|d<d|d<||_||_||_d|_t ||_|jd| g|_ |j D]@}t |}|d|j |Ad|_ |dS)a parent - parent of this dialog action - the name of the virtual event these keys will be mapped to current_key_sequences - a list of all key sequence lists currently mapped to virtual events, for overlap checking  borderwidthsunkenreliefFN)super__init__parentactioncurrent_key_sequencesresultr key_stringsetset_modifiers_for_platform modifier_varsrmappendadvancedcreate_widgets)selfr|r}r~modifiervariable __class__s ror{zGetKeysFrame.__init__1s    ]!X  %:" #D// B ''))) 0 0H H LL      % %h / / / /  rqc(tj|i|dSN)r showerror)rargskwargss rorzGetKeysFrame.showerrorLsd-f-----rqc t|d|_|jdddddt|jd|jd }|d t|jd |jd d}|dddt||_|jddddi|_d}t|j |j D]g\}}|j ||}t|j|j|||d}|d|dd ||j|<|dz }ht|jd d}|ddddd t!|jddd|_|jjdgt&R|jd |j|jdddd!"t-|jd#|jj$} |j| j%| dddd!"t5|jd&|j'|_|jddd(t|d)|_|jdddddt|jd d*|jd+d,z} | d t=|j|j-|_|jd.t||_ |j ddddt|j d d/} | ddd0t5||j!d12|_"|j"ddd3dd4|!dS)5N keyseq_basic)namernsew)rowcolumnstickypadxpadyzNew keys for 'z' :textw)anchorleftgrooveru)justify textvariablerxrvx)ipadxipadyfill)rrrrry)commandrronvalueoffvalue)rrrrzSelect 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.))rr)rr columnspanrr single)widthheight selectmodeendzns)rrrowspanrvertical)orientr)yscrollcommandz Clear Keys)rr)rrrkeyseq_advancedzEnter new binding(s) for 'z' : z2(These bindings will not be checked for validity!))r)raKey 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., .)rrr<< Basic Key Binding Entry)rrew)rrstickrr)#rframe_keyseq_basicgridr r}packrframe_controls_basicmodifier_checkbuttonsziprmrmodifier_labelrhr build_key_stringrlist_keys_finalinsertAVAILABLE_KEYSbindfinal_key_selectedr yviewconfigrr clear_key_seq button_clearframe_keyseq_advancedr advanced_keysframe_help_advanced toggle_level button_level) r basic_title basic_keysrrrlabelcheck help_basicscroll_keys_finaladvanced_title help_advanceds rorzGetKeysFrame.create_widgetsPs"'>"B"B"B $$1V+,1 % 6 6 6D3!B$+!B!B!BDDD $$$42F(,'(***  aqs333%*$KK! !&&1QvA&NNN&(""%dnd6H"I"I   Hh'++Hh??E 9(,(=E)18bRRRE JJ1V!CJ @ @ @38D &x 0 aKFF44f!<===  AaAAcJJJ 't'@.0X G G G##E;N;;;; !!"5t7NOOO !!a1T!JJJ%d&?-7.2.B.HJJJ ##3D3H#III1Q$GGG"4#<(4+/+=??? 1Q1===&+46G%H%H%H" "''Aa./a ( 9 9 9t96$S$S$S$S%Y%Z[[[ 3'''"4#=04AAA S)))$);;   %%!Af1%MMMd6@ B B B  q6:::#41B'CEEE 1QdKKK rqc^tjdkr gd|_n gd|_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. darwin)rgControlOptionCommand)rAltrgrCtrlN)sysplatformrmrrs rorz'GetKeysFrame.set_modifiers_for_platforms@ <8 # #FFFDNN888DN(&1rqc6|jddr||jd|j|j|j d|_ dS||jd|j |j d|_ dS) z'Toggle between basic and advanced keys.rAdvancedrrTzAdvanced Key Binding Entry >>FN) rcget startswithrrrliftrr focus_setrrrrs rorzGetKeysFrame.toggle_levels   " "6 * * 5 5j A A "      $ $*F $ G G G  & + + - - -  $ ) ) + + +   ( ( * * * DMMM      $ $*I $ J J J  # ( ( * * *  % * * , , ,!DMMMrqNc.|dS)z3Handler for clicking on key in basic settings list.N)rrevents rorzGetKeysFrame.final_key_selecteds rqc|x}}|jd}|r%t||}|||jdd|ddS)z2Create formatted string of modifiers plus the key.rrYrAr[N) get_modifiersrrhrprrrjoin)rkeylistrm final_keys rorzGetKeysFrame.build_key_strings"00222)(,,X66  &%i;;I NN9 % % % 4 1 144455555rqc<d|jD}d|DS)z9Return ordered list of modifiers that have been selected.c6g|]}|S)rh).0rs ro z.GetKeysFrame.get_modifiers..s FFFxHLLNNFFFrqcg|]}||Srr)rmods rorz.GetKeysFrame.get_modifiers..s///3////rq)r)rmod_lists rorzGetKeysFrame.get_modifierss,FF43EFFF//x////rqc|jdd|jdd|jD]}|d|jddS)z#Clear modifiers and keys selection.rrmovetoz0.0ryN)r select_clearrrrr)rrs rorzGetKeysFrame.clear_key_seqsw ))!U333 ""8U333*  H LL     Brqcd|_|j}|s||j|ddS|js||r||r||_dS)NryzNo key specified.titler|message) rrrhstriprkeyerror_titlerkeys_okbind_ok)rkeyss rookzGetKeysFrame.oks ""$$**,,  NN!4T#6  8 8 8 F M T\\$// T\\$5G5G DKrqc|jd}|}|j}d|jD}|ds|||dn|s*|ttzvr|||dnW|dgkr/|ttzd zvrd }||||n!||vrd }||||nd Sd S)zValidity check on user's 'basic' keybinding selection. Doesn't check the string produced by the advanced dialog because 'modifiers' isn't set. rcg|] }|D]}| Srr)rrrls rorz(GetKeysFrame.keys_ok..s<111(/11!$1111rqr[zMissing the final Key)r|rzNo modifier key(s) specified.rrg)rrzBThe shift modifier by itself may not be used with this key symbol.z'This key combination is already in use.TF) rrhrrr~endswithr FUNCTION_KEYS MOVE_KEYS)rrrrmr key_sequencesmsgs rorzGetKeysFrame.keys_oksR (,,X66 &&(( #11D,F111 }}S!!  NN5#:  < < < < =9#<<< NNt#B  D D D DG9$$#i/2BBCC&C NNtSN A A A A ] " ";C NNtSN A A A A4urqc ||d}|||dS#t$r+}||j|d|Yd}~dSd}~wwxYw)z:Return True if Tcl accepts the new keys else show message.cdSrrrrqroz&GetKeysFrame.bind_ok..sdrqTz2The entered key sequence is not accepted. Error: rNF)runbindrrr)rrbindingerrs rorzGetKeysFrame.bind_ok s iill33G KKg & & &4    NN-d-'*--  / / /55555  s1 A& A!!A&r)__name__ __module__ __qualname__rr{rrrrrrrrrrr __classcell__rs@rorsrs,s*N6...WWWr 2 2 2"""     666000       >       rqrscleZdZdddfd ZedZejdZd dZd dZxZ S) GetKeysWindowF)_htest_utestct||d|d<|dd|||dz|dzz z}||s/| dz| dzz ndz}| d|d|| |t|||x|_} |d|jt#|} t%| d d |j |_t%| d d |j |_|jd d dd|jd ddd| ddd| dd||t3|||s*||dSdS)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 rrvF)rrrurCWM_DELETE_WINDOWOK)rrrCancelr)rrrrrtopTboth)sideexpandrbottomr)r%rN)rzr{withdraw resizableupdate_idletasks winfo_rootx winfo_widthwinfo_reqwidth winfo_rooty winfo_heightwinfo_reqheightgeometryrrsframeprotocolcancelrrr button_ok button_cancelrr transientrgrab_set deiconify wait_window) rr|rr}r~rrryr2 frame_buttonsrs ror{zGetKeysWindow.__init__st     ] e5111     ! !  ""A%(;(;(=(=q(@@B    ! !%v""$$a'$*>*>*@*@!*CCC!$& k!kkakk""" 5)$8MNNN U ($+666d  D&':::#M)*DKAAA !!!<<< Aaaa@@@ d 888s333 vd   NN             rqc|jjSrr2rrs rorzGetKeysWindow.resultJs z  rqc||j_dSrr>)rvalues rorzGetKeysWindow.resultNs! rqNc|j||dSr)r2r grab_releasedestroyrs rorzGetKeysWindow.okRs4   rqcdd|_||dS)Nry)rrBrCrs ror4zGetKeysWindow.cancelWs,   rqr) rrrr{propertyrsetterrr4rrs@rorrs!,,,,,,,\!!X! ]""]" rqr__main__)mainz!idlelib.idle_test.test_config_keyruF) verbosityexit)run)%__doc__tkinterrrrr tkinter.ttkrrr r r r r tkinter.simpledialogrrirr tuplerjdigits ALPHANUM_KEYSPUNCTUATION_KEYSWHITESPACE_KEYS EDIT_KEYSr rrprsrrunittestrHidlelib.idle_test.htestrK GetKeysDialogrrqrorYs;:::::::::::KKKKKKKKKKKKKKKK...... 8 f,v}<== 5677, -  6 "22]B!"$-.09:(kkkkk5kkk\@@@@@H@@@F zD ,FFFF++++++C  rq