a  ze8@sddlmZmZmZmZddlmZmZmZm Z m Z m Z ddlm Z ddl mZddlZddlZdZeejejZedZdZd Zd ZeeeeeeZd d ZGd ddeZedkrddlmZeddddddl m!Z!e!edS))ToplevelListbox StringVarTclError)FrameButton CheckbuttonEntryLabel Scrollbar) messagebox) _setup_dialogN) ZF1ZF2ZF3ZF4ZF5ZF6ZF7ZF8ZF9ZF10ZF11ZF12z~!@#%^&*()_-+={}[]|;:,.<>/?)TabSpaceZReturn)Z BackSpaceZDeleteZInsert)ZHomeZEndPage Up Page Down Left Arrow Right ArrowUp Arrow Down Arrowc$Cs|ddddddddd d d d d ddddddddddddddddddd d!d"d#d$#}|||}d%|vrr|tjvrr|}d&|S)'NspaceZ asciitildeZexclamZatZ numbersignpercentZ asciicircumZ ampersandZasteriskZ parenleftZ parenrightZ underscoreZminusZplusZequalZ braceleftZ bracerightZ bracketleftZ bracketrightZbarZ semicoloncolonZcommaZperiodZlessZgreaterZslashZquestionZPriorZNextZLeftZRightZUpZDownr)#r~!@#%^&*()_-+={}[]|;:,.<>/?rrrrrrrShiftzKey-)getstringascii_lowercaseupper)key modifiersmappingr<F/opt/bitninja-python-dojo/embedded/lib/python3.9/idlelib/config_key.py translate_keys" r>c@seZdZdZdddddZddZdd Zd d Zd d ZdddZ ddZ ddZ ddZ d ddZ d!ddZddZddZdS)" GetKeysDialogzKey Sequence ErrorF)_htest_utestc CsJt||||jdd|jddd||||t||| d|j ||_ ||_ ||_ d|_t||_|jd|g|_|jD]"}t|}|d|j|qd|_|||d||d|d||s$|d|dnd f|sF| |!dS) N) borderwidthF)heightwidthZWM_DELETE_WINDOWz+%d+%d)"r__init__ZwithdrawZ configureZ resizabletitleZ transientr Zgrab_setprotocolcancelparentactioncurrent_key_sequencesresultr key_stringsetset_modifiers_for_platform modifier_varsr:appendadvancedcreate_widgetsZupdate_idletasksZgeometryZ winfo_rootxZ winfo_widthZwinfo_reqwidthZ winfo_rootyZ winfo_heightZwinfo_reqheightZ deiconifyZ wait_window) selfrMrJrNrOr@rAmodifiervariabler<r<r=rI1sN        zGetKeysDialog.__init__cOstj|i|dSN)r showerror)rXargskwargsr<r<r=r\bszGetKeysDialog.showerrorc Cs0t|ddd|_}|jddddt|}|jdd d t|d d |jd |_|jjdddddt|dd |jd |_|jjdddddt|dd|_ |j jddddddt |j d|j dd}|jddt |j d|j ddd}|jddd dt||_ |j jddddd i|_d}t|j|jD]T\}}|j||}t|j |j|||d!d"} | jd|ddd#| |j|<|d7}q.t |j dd$d%} | jddd&ddd't|j d(d)d*d+|_|jjd,gtR|jd-|j|jjdd&d&d.d/t|j d0|jjd1} |jj| jd2| jddd&d.d/t|j d3|j d4|_!|j!jddd&d5t|d6d|_"|j"jddddddt |j"dd7|j d8d9d%} | jddt#|j"|j d:|_$|j$jd d;t||_%|j%jddddd t |j%ddd?|_'|j'jddd@dddA|&dS)BNrGZsunken)rCrelieftopTZboth)sideexpandfillZbottomx)rarcZOK)textrEcommandrrB)rowcolumnpadxpadyZCancelZ keyseq_basic)nameZnsew)rhristickyrjrkzNew keys for 'z' :rfw)anchorleftZgroove)justify textvariabler_rC)ZipadxZipadyrc)rhrirnrjrF)rgrfrZZonvalueZoffvalue)rhrirjrnzSelect 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.))rsrf)rhri columnspanrjrn Zsingle)rErDZ selectmodeendzns)rhriZrowspanrnZvertical)Zorientrg)Zyscrollcommandz Clear Keys)rfrg)rhrirvZkeyseq_advancedzEnter new binding(s) for 'z' : z2(These bindings will not be checked for validity!))rt)rcaKey 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., .)rhrirn<< Basic Key Binding Entry)rgrfZew)rhriZstickrjrk)(rframepackrokZ button_okZgridrLZ button_cancelframe_keyseq_basicr rNrQframe_controls_basicZmodifier_checkbuttonszipr:rTmodifier_labelr5rbuild_key_stringrlist_keys_finalinsertAVAILABLE_KEYSbindfinal_key_selectedr yviewconfigrR clear_key_seqZ button_clearframe_keyseq_advancedr advanced_keysframe_help_advanced toggle_level button_level)rXr|Z frame_buttonsZ basic_titleZ basic_keysrirYrZZlabelcheckZ help_basicZscroll_keys_finalZadvanced_titleZ help_advancedr<r<r=rWfs           zGetKeysDialog.create_widgetscCs.tjdkrgd|_n gd|_ddi|_dS)Ndarwin)r4ControlZOptionZCommand)rZAltr4rZCtrl)sysplatformr:rrXr<r<r=rSs   z(GetKeysDialog.set_modifiers_for_platformcCs|jddrN||jjdd|j|j|j d|_ n0||jjdd|j |j d|_ dS)NrfZAdvancedr{roTzAdvanced Key Binding Entry >>F) rZcget startswithrrrZliftrrZ focus_setrVrrrr<r<r=rs     zGetKeysDialog.toggle_levelNcCs |dSr[)rrXeventr<r<r=rsz GetKeysDialog.final_key_selectedcCsN|}}|jd}|r0t||}|||jdd|ddS)Nrqr0r$r1) get_modifiersrr5r>rUrQrRjoin)rXkeylistr: final_keyr<r<r=rs     zGetKeysDialog.build_key_stringcCsdd|jD}dd|DS)NcSsg|] }|qSr<)r5).0rZr<r<r= z/GetKeysDialog.get_modifiers..cSsg|] }|r|qSr<r<)rmodr<r<r=rr)rT)rXZmod_listr<r<r=rszGetKeysDialog.get_modifierscCsB|jdd|jdd|jD]}|dq"|jddS)NrryZmovetoz0.0rF)rZ select_clearrrTrRrQ)rXrZr<r<r=rs   zGetKeysDialog.clear_key_seqcCs\|j}|s(|j|j|dddS|js8||rH||rH||_| | dS)NzNo key specified.rJrMmessage) rQr5stripr\keyerror_titlerVkeys_okbind_okrP grab_releasedestroy)rXrkeysr<r<r=r~s zGetKeysDialog.okcCsd|_||dS)NrF)rPrrrr<r<r=rLszGetKeysDialog.cancelcCs|jd}|}|j}dd|jD}|dsF|j||ddnt|sh|ttvrh|j||ddnR|d gkr|ttd vrd }|j|||dn"||vrd }|j|||dnd SdS)NrqcSsg|]}|D]}|q qSr<r<)rrr9r<r<r=rsz)GetKeysDialog.keys_ok..r1zMissing the final Key)rMrzNo modifier key(s) specified.rr4)rrzBThe shift modifier by itself may not be used with this key symbol.z'This key combination is already in use.TF) rr5rrrOendswithr\ FUNCTION_KEYS MOVE_KEYS)rXrrr:rJZ key_sequencesmsgr<r<r=rs4     zGetKeysDialog.keys_okc Cshz||dd}Wn>tyR}z&|j|j|d|dWYd}~dSd}~00|||dSdS)NcSsdSr[r<r<r<r<r=6rz'GetKeysDialog.bind_ok..z2The entered key sequence is not accepted. Error: rFT)rrr\rZunbind)rXrZbindingerrr<r<r=r3s zGetKeysDialog.bind_ok)N)N)N)__name__ __module__ __qualname__rrIr\rWrSrrrrrr~rLrrr<r<r<r=r?,s 1f   r?__main__)mainz!idlelib.idle_test.test_config_keyrGF) verbosityexit)run)"tkinterrrrrZ tkinter.ttkrrrr r r r Ztkinter.simpledialogr r6rrtupler7digitsZ ALPHANUM_KEYSZPUNCTUATION_KEYSZWHITESPACE_KEYSZ EDIT_KEYSrrr>r?rZunittestrZidlelib.idle_test.htestrr<r<r<r=s6