Your IP : 216.73.216.85


Current Path : /opt/alt/python38/lib64/python3.8/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/idlelib/__pycache__/config_key.cpython-38.opt-1.pyc

U

i�f�8�@s�dZddlmZmZmZmZddlmZmZm	Z	m
Z
mZmZddlm
Z
ddlmZddlZddlZdZeejej�Zed�Zd	Zd
ZdZeeeeeeZdd
�ZGdd�de�Zedkr�ddlm Z e dddd�ddl!m"Z"e"e�dS)z6
Dialog for building Tkinter accelerator key bindings
�)�Toplevel�Listbox�	StringVar�TclError)�Frame�Button�Checkbutton�Entry�Label�	Scrollbar)�
messagebox)�
_setup_dialogN)ZF1ZF2ZF3ZF4ZF5ZF6ZF7ZF8ZF9ZF10ZF11ZF12z~!@#%^&*()_-+={}[]|;:,.<>/?)�Tab�SpaceZReturn)Z	BackSpaceZDeleteZInsert)ZHomeZEnd�Page Up�	Page Down�
Left Arrow�Right Arrow�Up Arrow�
Down Arrowc$Cs|ddddddddd	d
ddd
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
bracerightZbracketleftZbracketrightZbarZ	semicolonZcolonZcommaZperiodZlessZgreaterZslashZquestionZPriorZNextZLeftZRightZUpZDownr)#r�~�!�@�#�%�^�&�*�(�)�_�-�+�=�{�}�[�]�|�;�:�,�.�<�>�/�?rrrrrrr�ShiftzKey-)�get�string�ascii_lowercase�upper)�key�	modifiers�mapping�r9�7/opt/alt/python38/lib64/python3.8/idlelib/config_key.py�
translate_keysP�r;c@s�eZdZdZddd�dd�Zdd�Zdd	�Zd
d�Zdd
�Zddd�Z	dd�Z
dd�Zdd�Zd dd�Z
d!dd�Zdd�Zdd�ZdS)"�
GetKeysDialogzKey Sequence ErrorF)�_htest�_utestc	CsJt�||�|��|jdd�|jddd�|�|�|�|�t|�|��|�	d|j
�||_||_||_
d|_t|�|_|j�d�|��g|_|jD]"}t|�}|�d�|j�|�q�d|_|��|��|�d|��|��d|��d|��|�s$|��d|��dnd	f�|�sF|� �|�!�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	transientr
Zgrab_setZprotocol�cancel�parent�action�current_key_sequences�resultr�
key_string�set�set_modifiers_for_platform�
modifier_varsr7�append�advanced�create_widgetsZupdate_idletasksZgeometryZwinfo_rootxZwinfo_widthZwinfo_reqwidthZwinfo_rootyZwinfo_heightZwinfo_reqheightZ	deiconifyZwait_window)	�selfrIrGrJrKr=r>�modifier�variabler9r9r:rF1sN




�����zGetKeysDialog.__init__cOstj||�dS�N)r�	showerror)rT�args�kwargsr9r9r:rXbszGetKeysDialog.showerrorc	Cs,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|jddd�}|jddd	d�t|�|_
|j
jddddd �i|_d}t|j|j�D]T\}}|j�||�}t|j
|j|||d!d"�}	|	jd|ddd#�|	|j|<|d7}�q.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�d9d%�}|jdd�t#|j"|jd:�|_$|j$jd	d;�t|�|_%|j%jddddd �t
|j%dd<d%�}
|
jdddd=�t||j&d>d?�|_'|j'jddd@dddA�|�&�dS)CNrDZsunken)r@�relief�topTZboth)�side�expand�fillZbottom�x)r]r_ZOK�)�textrB�commandrr?)�row�column�padx�padyZCancel�Zkeyseq_basic)�nameZnsew)rdre�stickyrfrgzNew keys for 'z' :�rb�w)�anchor�leftZgroove)�justify�textvariabler[r@)ZipadxZipadyr_)rdrerjrfrC)rcrbrVZonvalueZoffvalue)rdrerfrjz�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.))rorb�)rdre�
columnspanrfrj��
Zsingle)rBrAZ
selectmode�endz<ButtonRelease-1>�ns)rdreZrowspanrjZvertical)Zorientrc)Zyscrollcommandz
Clear Keys)rbrc)rdrerrZkeyseq_advancedzEnter new binding(s) for 'z' :
z2(These bindings will not be checked for validity!))rp)r_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>.)rdrerj�<< Basic Key Binding Entry)rcrbZew)rdreZstickrfrg)ru)(r�frameZpackr�okZ	button_okZgridrHZ
button_cancel�frame_keyseq_basicr
rJrM�frame_controls_basicZmodifier_checkbuttons�zipr7rP�modifier_labelr2r�build_key_stringr�list_keys_final�insert�AVAILABLE_KEYS�bind�final_key_selectedr�yview�configrN�
clear_key_seqZbutton_clear�frame_keyseq_advancedr	�
advanced_keys�frame_help_advanced�toggle_level�button_level)rTrxZ
frame_buttonsZbasic_titleZ
basic_keysrerUrVZlabelZcheckZ
help_basicZscroll_keys_finalZadvanced_titleZ
help_advancedr9r9r:rSfs������
�
��������
�
�zGetKeysDialog.create_widgetscCs4tjdkrddddg|_ndddg|_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.
        �darwinr1ZControlZOptionZCommandZAltZCtrlN)�sys�platformr7r}�rTr9r9r:rO�s
z(GetKeysDialog.set_modifiers_for_platformcCs�|j�d��d�rN|��|jjdd�|j��|j��|j�	�d|_
n0|��|jjdd�|j��|j��d|_
dS)	z'Toggle between basic and advanced keys.rbZAdvancedrwrkTzAdvanced Key Binding Entry >>FN)
r�Zcget�
startswithr�r�r�Zliftr�r�Z	focus_setrRrzr{r�r9r9r:r��s




zGetKeysDialog.toggle_levelNcCs|��dS)z3Handler for clicking on key in basic settings list.N)r~�rT�eventr9r9r:r��sz GetKeysDialog.final_key_selectedcCsN|��}}|j�d�}|r0t||�}|�|�|j�dd�|��d��dS)z2Create formatted string of modifiers plus the key.rmr-r!r.N)�
get_modifiersrr2r;rQrMrN�join)rT�keylistr7�	final_keyr9r9r:r~�s

zGetKeysDialog.build_key_stringcCsdd�|jD�}dd�|D�S)z9Return ordered list of modifiers that have been selected.cSsg|]}|���qSr9)r2)�.0rVr9r9r:�
<listcomp>�sz/GetKeysDialog.get_modifiers.<locals>.<listcomp>cSsg|]}|r|�qSr9r9)r��modr9r9r:r��s)rP)rTZmod_listr9r9r:r��szGetKeysDialog.get_modifierscCsB|j�dd�|j�dd�|jD]}|�d�q"|j�d�dS)z#Clear modifiers and keys selection.rruZmovetoz0.0rCN)rZselect_clearr�rPrNrM)rTrVr9r9r:r��s

zGetKeysDialog.clear_key_seqcCs\|j����}|s(|j|j|dd�dS|js8|�|�rH|�|�rH||_|�	�|�
�dS)NzNo key specified.�rGrI�message)rMr2�striprX�keyerror_titlerR�keys_ok�bind_okrL�grab_release�destroy)rTr��keysr9r9r:rys
�zGetKeysDialog.okcCsd|_|��|��dS)NrC)rLr�r�r�r9r9r:rHszGetKeysDialog.cancelcCs�|j�d�}|��}|j}dd�|jD�}|�d�sF|j||dd�nt|sh|ttkrh|j||dd�nR|d	gkr�|ttd
kr�d}|j|||d�n"||kr�d}|j|||d�nd
SdS)z�Validity check on user's 'basic' keybinding selection.

        Doesn't check the string produced by the advanced dialog because
        'modifiers' isn't set.
        rmcSsg|]}|D]}|�qqSr9r9)r�r�r6r9r9r:r�s�z)GetKeysDialog.keys_ok.<locals>.<listcomp>r.zMissing the final Key)rIr�zNo modifier key(s) specified.r�r1)rrzBThe shift modifier by itself may not be used with this key symbol.z'This key combination is already in use.TF)	rr2r�r�rK�endswithrX�
FUNCTION_KEYS�	MOVE_KEYS)rTr�r�r7rGZ
key_sequences�msgr9r9r:r�s4
�
��

��zGetKeysDialog.keys_okc
Csjz|�|dd��}Wn@tk
rT}z"|j|j|d|��d�WY�dSd}~XYnX|�||�dSdS)z:Return True if Tcl accepts the new keys else show message.cSsdSrWr9r9r9r9r:�<lambda>6�z'GetKeysDialog.bind_ok.<locals>.<lambda>z2The entered key sequence is not accepted.

Error: r�FNT)r�rrXr�Zunbind)rTr�Zbinding�errr9r9r:r�3s�zGetKeysDialog.bind_ok)N)N)N)�__name__�
__module__�__qualname__r�rFrXrSrOr�r�r~r�r�ryrHr�r�r9r9r9r:r<,s �1f
	

r<�__main__)�mainz!idlelib.idle_test.test_config_keyrDF)�	verbosity�exit)�run)#�__doc__ZtkinterrrrrZtkinter.ttkrrrr	r
rrZtkinter.simpledialogr
r3r�r��tupler4ZdigitsZ
ALPHANUM_KEYSZPUNCTUATION_KEYSZWHITESPACE_KEYSZ	EDIT_KEYSr�r�r;r<r�Zunittestr�Zidlelib.idle_test.htestr�r9r9r9r:�<module>s8 
���