Your IP : 216.73.216.196


Current Path : /opt/alt/python310/lib64/python3.10/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/idlelib/__pycache__/config_key.cpython-310.opt-1.pyc

o

0�i~;�@s
dZddlmZmZmZmZddlmZmZm	Z	m
Z
mZmZddlm
Z
ddlmZddlZddlZdZeejej�Zed�Zd	Zd
ZdZeeeeeeZdd
�ZGdd�de�ZGdd�de�Zedkr�ddl m!Z!e!dddd�ddl"m#Z#e#e$�dSdS)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 ArrowcCsidd�dd�dd�dd�d	d
�dd�d
d�dd�dd�dd�dd�dd�dd�dd�dd�dd �d!d"�id#d$�d%d&�d'd(�d)d*�d+d,�d-d.�d/d0�d1d2�d3d4�d5d6�d7d8�d9d:�d;d<�d=d>�d?d@�dAdB�dCdD��dEdEi�}|�||�}dF|vr�|tjvr�|��}dG|��S)Hz3Translate from keycap symbol to the Tkinter keysym.rZspace�~Z
asciitilde�!Zexclam�@Zat�#Z
numbersign�%Zpercent�^Zasciicircum�&Z	ampersand�*Zasterisk�(Z	parenleft�)Z
parenright�_Z
underscore�-Zminus�+Zplus�=Zequal�{Z	braceleft�}Z
braceright�[Zbracketleft�]Zbracketright�|Zbar�;Z	semicolon�:Zcolon�,Zcomma�.Zperiod�<Zless�>Zgreater�/Zslash�?ZquestionrZPriorrZNextrZLeftrZRightrZUprZDownr�ShiftzKey-)�get�string�ascii_lowercase�upper)�key�	modifiers�mapping�r9�9/opt/alt/python310/lib64/python3.10/idlelib/config_key.py�
translate_keys����������������������������	�	�
�
����
r;cszeZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Z�ZS)�GetKeysFramezKey Sequence Errorcs�t��|�d|d<d|d<||_||_||_d|_t|�|_|j�d�|�	�g|_
|jD]}t|�}|�d�|j
�|�q/d|_
|��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
        ��borderwidthZsunken�relief�FN)�super�__init__�parent�action�current_key_sequences�resultr�
key_string�set�set_modifiers_for_platform�
modifier_varsr7�append�advanced�create_widgets)�selfrCrDrE�modifier�variable��	__class__r9r:rB1s"


zGetKeysFrame.__init__cOstj|i|��dS�N)r�	showerror)rN�args�kwargsr9r9r:rTLszGetKeysFrame.showerrorc	Cs�t|dd�|_|jjdddddd�t|jd|j�d�d	�}|jd
d�t|jd|jd
dd�}|jdddd�t|�|_|jjddddd�i|_d}t	|j
|j�D])\}}|j�
||�}t|j|j|||dd�}|jd|dd
d�||j|<|d7}qRt|jddd�}|jddddd
d�t|jdddd�|_|jjdgt�R�|j�d |j�|jjdddd!d"�t|jd#|jjd$�}	|jj|	jd%�|	jdddd!d"�t|jd&|jd'�|_|jjdddd(�t|d)d�|_|jjdddddd�t|jdd*|j�d+�d,d�}
|
jd
d�t|j|jd-�|_|jjdd.�t|�|_ |j jddddd�t|j dd/d�}|jdddd0�t||j!d1d2�|_"|j"jddd3ddd4�|�!�dS)5NZkeyseq_basic)�namerZnsew�)�row�column�sticky�padx�padyzNew keys for 'z' :��text�w)�anchor�leftZgroover=)�justify�textvariabler?r>�x)ZipadxZipady�fill�)rYrZr[r\r@)�commandr_rPZonvalueZoffvalue)rYrZr\r[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.))rcr_�)rYrZ�
columnspanr\r[��
Zsingle)�width�heightZ
selectmode�endz<ButtonRelease-1>�ns)rYrZZrowspanr[Zvertical)Zorientrh)Zyscrollcommandz
Clear Keys)r_rh)rYrZrjZkeyseq_advancedzEnter new binding(s) for 'z' :
z2(These bindings will not be checked for validity!))rd)rfa�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>.)rYrZr[�<< Basic Key Binding Entry)rhr_Zew)rYrZZstickr\r])#r�frame_keyseq_basic�gridr
rD�packrG�frame_controls_basicZmodifier_checkbuttons�zipr7rJ�modifier_labelr2r�build_key_stringr�list_keys_final�insert�AVAILABLE_KEYS�bind�final_key_selectedr�yview�configrHr�
clear_key_seqZbutton_clear�frame_keyseq_advancedr	�
advanced_keys�frame_help_advanced�toggle_level�button_level)rNZbasic_titleZ
basic_keysrZrOrPZlabelZcheckZ
help_basicZscroll_keys_finalZadvanced_titleZ
help_advancedr9r9r:rMPs����
�

��������
�
�zGetKeysFrame.create_widgetscCs.tjdkrgd�|_ngd�|_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)r1�ControlZOptionZCommand)r�ZAltr1r�ZCtrlN)�sys�platformr7rw�rNr9r9r:rI�s

z'GetKeysFrame.set_modifiers_for_platformcCs�|j�d��d�r(|��|jjdd�|j��|j��|j�	�d|_
dS|��|jjdd�|j��|j��d|_
dS)	z'Toggle between basic and advanced keys.r_ZAdvancedrqr^TzAdvanced Key Binding Entry >>FN)
r�Zcget�
startswithr�rr�Zliftr�r�Z	focus_setrLrrrur�r9r9r:r��s






zGetKeysFrame.toggle_levelNcCs|��dS)z3Handler for clicking on key in basic settings list.N)rx�rNZeventr9r9r:r}��zGetKeysFrame.final_key_selectedcCsN|��}}|j�d�}|rt||�}|�|�|j�dd�|��d��dS)z2Create formatted string of modifiers plus the key.rar-r!r.N)�
get_modifiersryr2r;rKrGrH�join)rN�keylistr7�	final_keyr9r9r:rx�s

zGetKeysFrame.build_key_stringcCsdd�|jD�}dd�|D�S)z9Return ordered list of modifiers that have been selected.cSsg|]}|���qSr9)r2)�.0rPr9r9r:�
<listcomp>��z.GetKeysFrame.get_modifiers.<locals>.<listcomp>cSsg|]}|r|�qSr9r9)r��modr9r9r:r��r�)rJ)rNZmod_listr9r9r:r��szGetKeysFrame.get_modifierscCsB|j�dd�|j�dd�|jD]}|�d�q|j�d�dS)z#Clear modifiers and keys selection.rroZmovetoz0.0r@N)ryZselect_clearr~rJrHrG)rNrPr9r9r:r��s

zGetKeysFrame.clear_key_seqcCsRd|_|j����}|s|j|j|dd�dS|js|�|�r'|�|�r'||_dS)Nr@zNo key specified.��titlerC�message)	rFrGr2�striprT�keyerror_titlerL�keys_ok�bind_ok)rN�keysr9r9r:�ok�s
�zGetKeysFrame.okcCs�|j�d�}|��}|j}dd�|jD�}|�d�s$|j||dd�dS|s6|ttvr6|j||dd�dS|d	gkrO|ttd
vrOd}|j|||d�dS||vr_d}|j|||d�dSd
S)z�Validity check on user's 'basic' keybinding selection.

        Doesn't check the string produced by the advanced dialog because
        'modifiers' isn't set.
        racSsg|]	}|D]}|�qqSr9r9)r�r�r6r9r9r:r��s
�
�z(GetKeysFrame.keys_ok.<locals>.<listcomp>r.zMissing the final Key)rCr�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)	ryr2r�r�rE�endswithrT�
FUNCTION_KEYS�	MOVE_KEYS)rNr�r�r7r�Z
key_sequences�msgr9r9r:r��s6
���
�
���zGetKeysFrame.keys_okc
Csdz
|�|dd��}Wnty)}z|j|j|d|��d�WYd}~dSd}~ww|�||�dS)z:Return True if Tcl accepts the new keys else show message.cSsdSrSr9r9r9r9r:�<lambda>sz&GetKeysFrame.bind_ok.<locals>.<lambda>z2The entered key sequence is not accepted.

Error: r�NFT)r|rrTr�Zunbind)rNr�Zbinding�errr9r9r:r�s����zGetKeysFrame.bind_okrS)�__name__�
__module__�__qualname__r�rBrTrMrIr�r}rxr�r�r�r�r��
__classcell__r9r9rQr:r<,sY
	r<csReZdZddd��fdd�
Zedd��Zejdd��Zd
d	d
�Zd
dd�Z�Z	S)�
GetKeysWindowF)�_htest�_utestcsft��|�|��d|d<|jddd�|��|��|��d|��d}|��|s:|�	�d|�
�dnd}|�d|�d|���|�|�t
|||�|_}	|�d|j�t|�}
t|
d	d
|jd�|_t|
dd
|jd�|_|jjd
d
ddd�|jjd
dddd�|	jdddd�|
jddd�|�|�t|�|��|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
        rXr>F)rnrmr=�r"ZWM_DELETE_WINDOWZOK�)r_rmrhZCancelr)rYrZr\r]rg�topTZboth)�side�expandrfZbottomre)r�rfN)rArBZwithdrawZ	resizableZupdate_idletasksZwinfo_rootxZwinfo_widthZwinfo_reqwidthZwinfo_rootyZwinfo_heightZwinfo_reqheightZgeometryr�r<�frameZprotocol�cancelrrr�Z	button_okZ
button_cancelrsrtZ	transientr
Zgrab_setZ	deiconifyZwait_window)rNrCr�rDrEr�r�re�yr�Z
frame_buttonsrQr9r:rBsF���
��
�zGetKeysWindow.__init__cCs|jjSrS�r�rFr�r9r9r:rFJszGetKeysWindow.resultcCs||j_dSrSr�)rN�valuer9r9r:rFNr�NcCs|j��|��|��dSrS)r�r��grab_release�destroyr�r9r9r:r�Rs
zGetKeysWindow.okcCsd|_|��|��dS)Nr@)rFr�r�r�r9r9r:r�WszGetKeysWindow.cancelrS)
r�r�r�rB�propertyrF�setterr�r�r�r9r9rQr:r�s�.


r��__main__)�mainz!idlelib.idle_test.test_config_keyr=F)�	verbosity�exit)�run)%�__doc__ZtkinterrrrrZtkinter.ttkrrrr	r
rrZtkinter.simpledialogr
r3r�r��tupler4ZdigitsZ
ALPHANUM_KEYSZPUNCTUATION_KEYSZWHITESPACE_KEYSZ	EDIT_KEYSr�r{r;r<r�r�Zunittestr�Zidlelib.idle_test.htestr�Z
GetKeysDialogr9r9r9r:�<module>s< 
���oC�