Edit File: config_key.cpython-37.pyc
B ����r}�c�8������������������@���s����d�Z�ddlmZmZmZmZ�ddlmZmZm Z m Z mZmZ�ddlm Z �ddlZddlZdZeejej��Zed�ZdZd Zd Zee�e�e�e�e�Zdd��ZG�d d��de�Zedkr�ddlmZ�edddd��ddlm Z �e e��dS�)z6 Dialog for building Tkinter accelerator key bindings �����)�Toplevel�Listbox� StringVar�TclError)�Frame�Button�Checkbutton�Entry�Label� Scrollbar)� messageboxN)ZF1ZF2ZF3ZF4ZF5ZF6ZF7ZF8ZF9ZF10ZF11ZF12z~!@#%^&*()_-+={}[]|;:,.<>/?)�Tab�SpaceZReturn)Z BackSpaceZDeleteZInsert)ZHomeZEndzPage Upz Page Downz Left ArrowzRight ArrowzUp Arrowz Down Arrowc����������$���C���s|���ddddddddd d ddd ddddddddddddddddddd d!d"d#d$�#}|��|�|��}�d%|krr|�tjkrr|����}�d&|����S�)'z3Translate from keycap symbol to the Tkinter keysym.ZspaceZ asciitildeZexclamZatZ numbersignZpercentZasciicircumZ ampersandZasteriskZ parenleftZ parenrightZ underscoreZminusZplusZequalZ braceleftZ bracerightZbracketleftZbracketrightZbarZ semicolonZcolonZcommaZperiodZlessZgreaterZslashZquestionZPriorZNextZLeftZRightZUpZDownr ���)#r����~�!�@�#�%�^�&�*�(�)�_�-�+�=�{�}�[�]�|�;�:�,�.�<�>�/�?zPage Upz Page Downz Left ArrowzRight ArrowzUp Arrowz Down Arrowr ����ShiftzKey-)�get�string�ascii_lowercase�upper)�key� modifiers�mapping��r2����7/opt/alt/python37/lib64/python3.7/idlelib/config_key.py� translate_key���s ����r4���c���������������@���s����e�Zd�ZdZddd�dd�Zdd��Zdd ��Zd d��Zdd ��Zddd�Z dd��Z dd��Zdd��Zd dd�Z d!dd�Zdd��Zdd��ZdS�)"� GetKeysDialogzKey Sequence ErrorF)�_htest�_utestc������ ������C���sF��t��|�|��|�����|�jdd��|�jddd��|��|��|��|��|�����|��d|�j ��||�_ ||�_||�_d|�_ t|��|�_|�j�d��|�����g�|�_x,|�jD�]"}t|��}|�d��|�j�|��q�W�d|�_|�����|�����|��d|���|���d�|����d���|���|�s |���d�|����d��nd �f���|�sB|�����|�� ���d S�)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 ����)�borderwidthF)�height�widthZWM_DELETE_WINDOW��z+%d+%d��������N)!r����__init__ZwithdrawZ configureZ resizable�titleZ transientZgrab_setZprotocol�cancel�parent�action�current_key_sequences�resultr���� key_string�set�set_modifiers_for_platform� modifier_varsr0����append�advanced�create_widgetsZupdate_idletasksZgeometryZwinfo_rootxZwinfo_widthZwinfo_reqwidthZwinfo_rootyZwinfo_heightZwinfo_reqheightZ deiconifyZwait_window) �selfrB���r@���rC���rD���r6���r7����modifier�variabler2���r2���r3���r?���0���s@���� *zGetKeysDialog.__init__c�������������O���s���t�j||��d�S�)N)r���� showerror)rM����args�kwargsr2���r2���r3���rP���`���s����zGetKeysDialog.showerrorc���������� ���C���s0��t�|�ddd��|�_}|jdddd��t�|��}|jdd d ��t|dd|�jd �|�_|�jjddddd��t|dd|�jd �|�_|�jjddddd��t�|dd�|�_ |�j jdddddd��t |�j d|�j��d�d�}|jdd��t |�j d|�jddd�}|jddd d��t�|�|�_ |�j jddddd ��i�|�_d}xft|�j|�j�D�]T\}}|�j�||�}t|�j |�j|||d!d"�} | jd|ddd#��| |�j|<�|d7�}�q0W�t |�j dd$d%�} | jddd&ddd'��t|�j d(d)d*d+�|�_|�jjdBt����|�j�d-|�j��|�jjdd&d&d.d/��t|�j d0|�jjd1�}|�jj|jd2��|jddd&d.d/��t|�j d3|�j d4�|�_!|�j!jddd&d5��t�|d6d�|�_"|�j"jdddddd��t |�j"dd7|�j��d8�d9�d%�}|jdd��t#|�j"|�jd:�|�_$|�j$jd d;��t�|�|�_%|�j%jddddd ��t |�j%dd<d%�} | jdddd=��t||�j&d>d?�|�_'|�j'jddd@dddA��|��&���d�S�)CNr=���Zsunken)r9����relief�topTZboth)�side�expand�fillZbottom�x)rU���rW���ZOK����)�textr;����commandr���r8���)�row�column�padx�padyZCancel����Zkeyseq_basic)�nameZnsew)r\���r]����stickyr^���r_���zNew keys for 'z' :)rZ����w)�anchor�leftZgroove)�justify�textvariablerS���r9���)ZipadxZipadyrW���)r\���r]���rb���r^���r<���)r[���rZ���rO���ZonvalueZoffvalue)r\���r]���r^���rb���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.))rf���rZ�������)r\���r]���� columnspanr^���rb�������� ���Zsingle)r;���r:���Z selectmode�endz<ButtonRelease-1>�ns)r\���r]���Zrowspanrb���Zvertical)Zorientr[���)Zyscrollcommandz Clear Keys)rZ���r[���)r\���r]���ri���Zkeyseq_advancedzEnter new binding(s) for 'z' : z2(These bindings will not be checked for validity!))rg���)rW���a���Key bindings are specified using Tkinter keysyms as in these samples: <Control-f>, <Shift-F2>, <F12>, <Control-space>, <Meta-less>, <Control-Alt-Shift-X>. Upper case is used when the Shift modifier is present! 'Emacs style' multi-keystroke bindings are specified as follows: <Control-x><Control-y>, where the first key is the 'do-nothing' keybinding. Multiple separate bindings for one action should be separated by a space, eg., <Alt-v> <Meta-v>.)r\���r]���rb���z<< Basic Key Binding Entry)r[���rZ���Zew)r\���r]���Zstickr^���r_���)rl���)(r����frameZpackr����okZ button_okZgridrA���Z button_cancel�frame_keyseq_basicr ���rC���rF����frame_controls_basicZmodifier_checkbuttons�zipr0���rI����modifier_labelr+���r����build_key_stringr����list_keys_final�insert�AVAILABLE_KEYS�bind�final_key_selectedr����yview�configrG���� clear_key_seqZbutton_clear�frame_keyseq_advancedr ���� advanced_keys�frame_help_advanced�toggle_level�button_level)rM���rn���Z frame_buttonsZbasic_titleZ basic_keysr]���rN���rO���ZlabelZcheckZ help_basicZscroll_keys_finalZadvanced_titleZ help_advancedr2���r2���r3���rL���d���s����� zGetKeysDialog.create_widgetsc�������������C���s4���t�jdkrddddg|�_ndddg|�_ddi|�_dS�) aV��Determine 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. �darwinr*���ZControlZOptionZCommandZAltZCtrlN)�sys�platformr0���rs���)rM���r2���r2���r3���rH�������s���� z(GetKeysDialog.set_modifiers_for_platformc�������������C���s����|�j��d��d�rN|�����|�j�jdd��|�j����|�j����|�j� ���d|�_ n0|�����|�j�jdd��|�j����|�j����d|�_ dS�) z'Toggle between basic and advanced keys.rZ���ZAdvancedz<< Basic Key Binding Entry)rZ���TzAdvanced Key Binding Entry >>FN) r����Zcget� startswithr|���r{���r}���Zliftr���r~���Z focus_setrK���rp���rq���)rM���r2���r2���r3���r��������s���� zGetKeysDialog.toggle_levelNc�������������C���s���|������dS�)z3Handler for clicking on key in basic settings list.N)rt���)rM����eventr2���r2���r3���ry�������s����z GetKeysDialog.final_key_selectedc�������������C���sN���|������}}|�j�d�}|r0t||�}|�|��|�j�dd�|���d���dS�)z2Create formatted string of modifiers plus the key.rd���r&���r���r'���N)� get_modifiersru���r+���r4���rJ���rF���rG����join)rM����keylistr0���� final_keyr2���r2���r3���rt�������s���� zGetKeysDialog.build_key_stringc�������������C���s���dd��|�j�D��}dd��|D��S�)z9Return ordered list of modifiers that have been selected.c�������������S���s���g�|�]}|�����qS�r2���)r+���)�.0rO���r2���r2���r3���� <listcomp>����s����z/GetKeysDialog.get_modifiers.<locals>.<listcomp>c�������������S���s���g�|�]}|r|�qS�r2���r2���)r�����modr2���r2���r3���r��������s����)rI���)rM���Zmod_listr2���r2���r3���r��������s����zGetKeysDialog.get_modifiersc�������������C���sF���|�j��dd��|�j��dd��x|�jD�]}|�d��q$W�|�j�d��dS�)z#Clear modifiers and keys selection.r���rl���Zmovetoz0.0r<���N)ru���Zselect_clearrz���rI���rG���rF���)rM���rO���r2���r2���r3���r|�������s ����zGetKeysDialog.clear_key_seqc�������������C���s\���|�j�������}|s(|�j|�j|�dd��d�S�|�js8|��|�rH|��|�rH||�_|�� ���|�� ���d�S�)NzNo key specified.)r@���rB����message)rF���r+����striprP����keyerror_titlerK����keys_ok�bind_okrE����grab_release�destroy)rM���r�����keysr2���r2���r3���ro�����s���� zGetKeysDialog.okc�������������C���s���d|�_�|�����|�����d�S�)Nr<���)rE���r����r����)rM���r����r2���r2���r3���rA��� ��s����zGetKeysDialog.cancelc�������������C���s����|�j��d�}|����}|�j}dd��|�jD��}|�d�sF|�j||�dd��nt|sh|tt�krh|�j||�dd��nR|d gkr�|tt�d �kr�d}|�j||�|d��n"||kr�d}|�j||�|d��nd S�dS�)z�Validity check on user's 'basic' keybinding selection. Doesn't check the string produced by the advanced dialog because 'modifiers' isn't set. rd���c�������������S���s���g�|�]}|D�]}|�qqS�r2���r2���)r����r����r/���r2���r2���r3���r������s����z)GetKeysDialog.keys_ok.<locals>.<listcomp>r'���zMissing the final Key)rB���r����zNo modifier key(s) specified.)r@���rB���r����r*���)r ���r���zBThe shift modifier by itself may not be used with this key symbol.z'This key combination is already in use.TF) ru���r+���r����r����rD����endswithrP���� FUNCTION_KEYS� MOVE_KEYS)rM���r����r����r0���r@���Z key_sequences�msgr2���r2���r3���r������s*���� zGetKeysDialog.keys_okc���������� ���C���sd���y|���|dd���}W�n:�tk rN�}�z|�j|�j|�d|���d��dS�d}~X�Y�nX�|��||��dS�dS�)z:Return True if Tcl accepts the new keys else show message.c���������������S���s���d�S�)Nr2���r2���r2���r2���r3����<lambda>4�������z'GetKeysDialog.bind_ok.<locals>.<lambda>z2The entered key sequence is not accepted. Error: )r@���rB���r����FNT)rx���r���rP���r����Zunbind)rM���r����Zbinding�errr2���r2���r3���r����1��s����zGetKeysDialog.bind_ok)N)N)N)�__name__� __module__�__qualname__r����r?���rP���rL���rH���r����ry���rt���r����r|���ro���rA���r����r����r2���r2���r2���r3���r5���+���s���/f r5����__main__)�mainz!idlelib.idle_test.test_config_keyr=���F)� verbosity�exit)�run)!�__doc__Ztkinterr���r���r���r���Ztkinter.ttkr���r���r���r ���r ���r���r���r,���r����r�����tupler-���ZdigitsZ ALPHANUM_KEYSZPUNCTUATION_KEYSZWHITESPACE_KEYSZ EDIT_KEYSr����rw���r4���r5���r����Zunittestr����Zidlelib.idle_test.htestr����r2���r2���r2���r3����<module>���s*��� ��