Your IP : 3.15.203.195


Current Path : /opt/alt/python36/lib64/python3.6/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/idlelib/__pycache__/config_key.cpython-36.pyc

3

� f`4�@s~dZddlTddlmZddlmZddlZddlZGdd�de�Ze	dkrzdd	l
mZed
ddd
�ddlm
Z
e
e�dS)z6
Dialog for building Tkinter accelerator key bindings
�)�*)�	Scrollbar)�
messageboxNc@s�eZdZdZddd�dd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zd#dd�Zd$dd�Zdd �Zd!d"�ZdS)%�
GetKeysDialogzKey Sequence ErrorF)�_htest�_utestc	CsNtj||�|j�|jdd�|jttd�|j|�|j|�|j�|j	d|j
�||_||_||_
d|_t|�|_|jjd�|j�g|_x,|jD]"}t|�}|jd�|jj|�q�Wd|_|j�|j�|j�|jd|j�|j�d|j�d|j�|�s(|j�d|j �dnd	f�|�sJ|j!�|j"�d
S)al
        action - string, the name of the virtual event these keys will be
                 mapped to
        currentKeys - list, a list of all key sequence lists currently mapped
                 to virtual events, for overlap checking
        _utest - bool, do not wait when running unittest
        _htest - bool, change box location when running htest
        �)�borderwidth)�height�widthZWM_DELETE_WINDOW�Fz+%d+%d��N)#�Toplevel�__init__ZwithdrawZ	configureZ	resizableZFALSE�titleZ	transientZgrab_setZprotocol�Cancel�parent�action�currentKeySequences�resultZ	StringVar�	keyString�set�SetModifiersForPlatform�
modifier_vars�	modifiers�append�advanced�
CreateWidgets�LoadFinalKeyListZupdate_idletasksZgeometryZwinfo_rootxZwinfo_widthZwinfo_reqwidthZwinfo_rootyZwinfo_heightZwinfo_reqheightZ	deiconifyZwait_window)	�selfrrrrrr�modifier�variable�r#�7/opt/alt/python36/lib64/python3.6/idlelib/config_key.pyrsB




*zGetKeysDialog.__init__cOstj||�dS)N)r�	showerror)r �args�kwargsr#r#r$r%>szGetKeysDialog.showerrorc	Cst|dtd�}|jtttd�t|�}|jttd�t|dd|j	d�|_
|j
jddd	d	d
�t|dd|jd�|_
|j
jddd	d	d
�t|�|_t|�|_t|�|_t|�|_|jjddtd	d	d
�|jjddtd	d	d
�|jj�|jjddtd	d�|jjddtd	d�|jj�t||jdd�|_|jjddtd	d	d�t|jd|jdd�}|jtd�t|jt|jtdd�}|jd	d	td�i|_d}xft|j|j �D]T\}}|j!j"||�}t#|j|j$|||dd�}	|	jd|dtd�|	|j|<|d7}�q�Wt|jtd?d!�}
|
jddd"dtd#�t%|jd$d%t&d&�|_'|j'j(d'|j)�|j'jdd"d"t*d(�t+|jt,|j'j-d)�}|j'j.|j/d*�|jdd	d"t*d(�t|jd+|j0d,�|_1|j1jddd"d-�t|jtd.|jd/d0d!�}|jtd�t2|j|jd1�|_3|j3jtd2�t|jtdEd!�}
|
jddtd:�dS)FNr
)r	�relief)�side�expand�fill)r)r+�OK�)�textr�commandrr)�row�column�padx�padyr�)r0r1�stickyr2r3)r0r1r5r2zAdvanced Key Binding Entry >>)r/r.)r0r1Zstickr2r3zNew keys for  'z' :)r.)Zanchor)�justify�textvariabler(r	)ZipadxZipadyr+r)r/r.r"ZonvalueZoffvalue)r0r1r2r5z!Select the desired modifier keys
z"above, and the final key from the
zlist on the right.

z"Use upper case Symbols when using
z&the Shift modifier.  (Letters will be
zconverted automatically.))r6r.�)r0r1�
columnspanr2r5��
)rr
Z
selectmodez<ButtonRelease-1>)r0r1Zrowspanr5)Zorientr/)Zyscrollcommandz
Clear Keys)r.r/)r0r1r9zEnter new binding(s) for  'z' :
z2(These bindings will not be checked for validity!))r7)r+z4Key bindings are specified using Tkinter keysyms as
z�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!

z8'Emacs style' multi-keystroke bindings are specified as
z5follows: <Control-x><Control-y>, where the first key
z!is the 'do-nothing' keybinding.

z4Multiple separate bindings for one action should be
z,separated by a space, eg., <Alt-v> <Meta-v>.)r0r1r5zCSelect the desired modifier keys
above, and the final key from the
zWSelect the desired modifier keys
above, and the final key from the
list on the right.

zySelect the desired modifier keys
above, and the final key from the
list on the right.

Use upper case Symbols when using
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
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.)z�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!

aKey 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
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
aaKey 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.

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
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>.)4ZFrameZSUNKENZpackZTOPZTRUEZBOTHZBOTTOM�XZButtonr,ZbuttonOKZgridrZbuttonCancel�frameKeySeqBasic�frameKeySeqAdvanced�frameControlsBasic�frameHelpAdvancedZNSEW�lift�ToggleLevel�buttonLevelZEWZLabelr�WZLEFTrZGROOVEZmodifier_checkbuttons�ziprr�modifier_label�getZCheckbutton�BuildKeyStringZListboxZSINGLE�
listKeysFinal�bind�FinalKeySelectedZNSrZVERTICAL�yview�configr�ClearKeySeqZbuttonClearZEntry�entryKeysAdvanced)r Z	frameMainZframeButtonsZlabelTitleBasicZlabelKeysBasicr1r!r"ZlabelZcheckZ
labelFnAdviceZscrollKeysFinalZlabelTitleAdvancedZlabelHelpAdvancedr#r#r$rBs�










zGetKeysDialog.CreateWidgetscCs4tjdkrddddg|_ndddg|_ddi|_dS)	aUDetermine 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�ShiftZControlZOptionZCommandZAltZCtrlN)�sys�platformrrF)r r#r#r$r�s
z%GetKeysDialog.SetModifiersForPlatformcCs�|jjd�dd�dkrT|j�|jjdd�|jj�|jj�|jj�d|_	n0|j�|jjdd�|j
j�|jj�d|_	dS)	Nr.r-ZAdvancedz<< Basic Key Binding Entry)r.TzAdvanced Key Binding Entry >>F)rCZcgetrNrMr>rAr@rOZ	focus_setrr=r?)r r#r#r$rB�s




zGetKeysDialog.ToggleLevelcCs|j�dS)N)rH)r �eventr#r#r$rK�szGetKeysDialog.FinalKeySelectedcCsP|j�}}|jjt�}|r2|j||�}|j|�|jjddj|�d�dS)N�<�-�>)	�GetModifiersrIrG�ANCHOR�TranslateKeyrrr�join)r ZkeyListr�finalKeyr#r#r$rH�s
zGetKeysDialog.BuildKeyStringcCsdd�|jD�}dd�|D�S)NcSsg|]}|j��qSr#)rG)�.0r"r#r#r$�
<listcomp>�sz.GetKeysDialog.GetModifiers.<locals>.<listcomp>cSsg|]}|r|�qSr#r#)r]�modr#r#r$r^�s)r)r ZmodListr#r#r$rX�szGetKeysDialog.GetModifierscCsF|jjdt�|jjtd�x|jD]}|jd�q$W|jjd�dS)Nrz0.0r)rIZselect_clear�ENDrLZMOVETOrrr)r r"r#r#r$rN�s
zGetKeysDialog.ClearKeySeqcCsnd|_ttjtj�|_td
�|_d|_d|_d|_	|j|j|j|j|j|j	}|j
jtf|��dS) N�F1�F2�F3�F4�F5�F6�F7�F8�F9�F10�F11�F12z~!@#%^&*()_-+={}[]|;:,.<>/?�Tab�Space�Return�	BackSpace�Delete�Insert�Home�End�Page Up�	Page Down�
Left Arrow�Right Arrow�Up Arrow�
Down Arrow)rarbrcrdrerfrgrhrirjrkrl)rmrnro)rprqrr)rsrtrurvrwrxryrz)
�functionKeys�tuple�string�ascii_lowercaseZdigitsZalphanumKeysZpunctuationKeysZwhitespaceKeysZeditKeys�moveKeysrI�insertr`)r �keysr#r#r$r�s
$zGetKeysDialog.LoadFinalKeyListc$Cs�ddddddddd	d
ddd
ddddddddddddddddddd d!d"d#d$�#}||kr\||}d%|krv|tjkrv|j�}d&|}|S)'z2Translate from keycap symbol to the Tkinter keysymZspaceZ
asciitildeZexclamZatZ
numbersignZpercentZasciicircumZ	ampersandZasteriskZ	parenleftZ
parenrightZ
underscoreZminusZplusZequalZ	braceleftZ
bracerightZbracketleftZbracketrightZbarZ	semicolonZcolonZcommaZperiodZlessZgreaterZslashZquestionZPriorZNextZLeftZRightZUpZDownrm)#rn�~�!�@�#�%�^�&r�(�)�_rV�+�=�{�}�[�]�|�;�:�,�.rUrW�/�?zPage Upz	Page Downz
Left ArrowzRight ArrowzUp Arrowz
Down ArrowrmrQzKey-)r}r~�upper)r �keyrZ
translateDictr#r#r$rZ�s 

zGetKeysDialog.TranslateKeyNcCs\|jj�j�}|s(|j|j|dd�dS|js8|j|�rH|j|�rH||_|j	�|j
�dS)NzNo key specified.)rr�message)rrG�stripr%�keyerror_titler�KeysOK�bind_okr�grab_release�destroy)r rTr�r#r#r$r,�s
zGetKeysDialog.OKcCsd|_|j�|j�dS)Nr)rr�r�)r rTr#r#r$r�szGetKeysDialog.CancelcCs�|jjt�}|j�}d}|j}dd�|jD�}|jd�sJ|j||dd�n~|rr||j|j	krr|j||dd�nV|d	gkr�||j|j	dkr�d}|j|||d�n"||kr�d
}|j|||d�nd}|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.

        FcSsg|]}|D]}|�qqSr#r#)r]Zkeylistr�r#r#r$r^sz(GetKeysDialog.KeysOK.<locals>.<listcomp>rWzMissing the final Key)rr�zNo modifier key(s) specified.)rrr�rQrmrnzBThe shift modifier by itself may not be used with this key symbol.z'This key combination is already in use.T)rmrn)
rIrGrYrXr�r�endswithr%r{r)r r�r\rZkeysOKrZ
key_sequences�msgr#r#r$r��s,



zGetKeysDialog.KeysOKcCsby|j|dd��}Wn8tk
rL}z|j|j|d|��d�dSd}~XnX|j||�dSdS)z:Return True if Tcl accepts the new keys else show message.cSsdS)Nr#r#r#r#r$�<lambda>sz'GetKeysDialog.bind_ok.<locals>.<lambda>z2The entered key sequence is not accepted.

Error: )rrr�FNT)rJZTclErrorr%r�Zunbind)r r�Zbinding�errr#r#r$r�szGetKeysDialog.bind_ok)N)N)�__name__�
__module__�__qualname__r�rr%rrrBrKrHrXrNrrZr,rr�r�r#r#r#r$rs -O

!r�__main__)�mainz!idlelib.idle_test.test_config_keyr
F)�	verbosity�exit)�run)�__doc__ZtkinterZtkinter.ttkrrr}rRrrr�Zunittestr�Zidlelib.idle_test.htestr�r#r#r#r$�<module>s

?>