<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
3
 f`4                 @   s~   d Z ddlT ddlmZ ddlmZ ddlZddlZG dd deZe	dkrzdd	l
mZ ed
ddd ddlmZ ee dS )z6
Dialog for building Tkinter accelerator key bindings
    )*)	Scrollbar)
messageboxNc               @   s   e Zd ZdZdddddZdd Zdd	 Zd
d Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zd#ddZd$ddZdd  Zd!d" ZdS )%GetKeysDialogzKey Sequence ErrorF)_htest_utestc      	      C   sN  t j| | | j  | jdd | jttd | j| | j| | j  | j	d| j
 || _|| _|| _d| _t| | _| jjd | j  g | _x,| jD ]"}t| }|jd | jj| qW d| _| j  | j  | j  | jd|j |j d | j d   |j |s(|j d | j  d  nd	 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widthZWM_DELETE_WINDOW Fz+%d+%d      N)#Toplevel__init__ZwithdrawZ	configureZ	resizableZFALSEtitleZ	transientZgrab_setZprotocolCancelparentactioncurrentKeySequencesresultZ	StringVar	keyStringsetSetModifiersForPlatformmodifier_vars	modifiersappendadvancedCreateWidgetsLoadFinalKeyListZupdate_idletasksZgeometryZwinfo_rootxZwinfo_widthZwinfo_reqwidthZwinfo_rootyZwinfo_heightZwinfo_reqheightZ	deiconifyZwait_window)	selfr   r   r   r   r   r   modifiervariable r#   7/opt/alt/python36/lib64/python3.6/idlelib/config_key.pyr      sB    




*zGetKeysDialog.__init__c             O   s   t j|| d S )N)r   	showerror)r    argskwargsr#   r#   r$   r%   >   s    zGetKeysDialog.showerrorc          	   C   s  t | dtd}|jtttd t | }|jttd t|dd| j	d| _
| j
jddd	d	d
 t|dd| jd| _| jjddd	d	d
 t || _t || _t || _t || _| jjddtd	d	d | jjddtd	d	d | jj  | jjddtd	d | jjddtd	d | jj  t|| jdd| _| jjddtd	d	d t| jd| j d d}|jtd t| jt| jtdd}|jd	d	td i | _d}xft| j| j D ]T\}}| j!j"||}t#| j| j$|||dd}	|	jd|dtd |	| j|< |d7 }qW t| jtd?d!}
|
jddd"dtd# t%| jd$d%t&d&| _'| j'j(d'| j) | j'jdd"d"t*d( t+| jt,| j'j-d)}| j'j.|j/d* |jdd	d"t*d( t| jd+| j0d,| _1| j1jddd"d- t| jtd.| j d/ d0 d!}|jtd t2| j| jd1| _3| j3jtd2 t| jtdEd!}|jddtd: d S )FNr   )r	   relief)sideexpandfill)r)   r+   OK   )textr   commandr   r   )rowcolumnpadxpadyr      )r0   r1   stickyr2   r3   )r0   r1   r5   r2   zAdvanced Key Binding Entry >>)r/   r.   )r0   r1   Zstickr2   r3   zNew keys for  'z' :)r.   )Zanchor)justifytextvariabler(   r	   )ZipadxZipadyr+   r   )r/   r.   r"   ZonvalueZoffvalue)r0   r1   r2   r5   z!Select the desired modifier keys
z"above, and the final key from the
zlist on the right.

z"Use upper case Symbols when using
z&the Shift modifier.  (Letters will be
zconverted automatically.))r6   r.      )r0   r1   
columnspanr2   r5      
   )r   r
   Z
selectmodez<ButtonRelease-1>)r0   r1   Zrowspanr5   )Zorientr/   )Zyscrollcommandz
Clear Keys)r.   r/   )r0   r1   r9   zEnter new binding(s) for  'z' :
z2(These bindings will not be checked for validity!))r7   )r+   z4Key bindings are specified using Tkinter keysyms as
zin 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>.)r0   r1   r5   zCSelect 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
zSelect 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
zSelect 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.)zKey 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!

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
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
aa  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.

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>.)4ZFrameZSUNKENZpackZTOPZTRUEZBOTHZBOTTOMXZButtonr,   ZbuttonOKZgridr   ZbuttonCancelframeKeySeqBasicframeKeySeqAdvancedframeControlsBasicframeHelpAdvancedZNSEWliftToggleLevelbuttonLevelZEWZLabelr   WZLEFTr   ZGROOVEZmodifier_checkbuttonszipr   r   modifier_labelgetZCheckbuttonBuildKeyStringZListboxZSINGLElistKeysFinalbindFinalKeySelectedZNSr   ZVERTICALyviewconfigr   ClearKeySeqZbuttonClearZEntryentryKeysAdvanced)r    Z	frameMainZframeButtonsZlabelTitleBasicZlabelKeysBasicr1   r!   r"   ZlabelZcheckZlabelFnAdviceZscrollKeysFinalZlabelTitleAdvancedZlabelHelpAdvancedr#   r#   r$   r   B   s    







 


 zGetKeysDialog.CreateWidgetsc             C   s4   t jdkrddddg| _ndddg| _ddi| _dS )	aU  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.
        darwinShiftZControlZOptionZCommandZAltZCtrlN)sysplatformr   rF   )r    r#   r#   r$   r      s    
z%GetKeysDialog.SetModifiersForPlatformc             C   s   | j jdd d dkrT| j  | j jdd | jj  | jj  | jj  d| _	n0| j  | j jdd | j
j  | jj  d| _	d S )	Nr.   r-   ZAdvancedz<< Basic Key Binding Entry)r.   TzAdvanced Key Binding Entry >>F)rC   ZcgetrN   rM   r>   rA   r@   rO   Z	focus_setr   r=   r?   )r    r#   r#   r$   rB      s    




zGetKeysDialog.ToggleLevelc             C   s   | j   d S )N)rH   )r    eventr#   r#   r$   rK      s    zGetKeysDialog.FinalKeySelectedc             C   sP   | j   }}| jjt}|r2| j||}|j| | jjddj| d  d S )N<->)	GetModifiersrI   rG   ANCHORTranslateKeyr   r   r   join)r    ZkeyListr   finalKeyr#   r#   r$   rH      s    
zGetKeysDialog.BuildKeyStringc             C   s   dd | j D }dd |D S )Nc             S   s   g | ]}|j  qS r#   )rG   ).0r"   r#   r#   r$   
<listcomp>   s    z.GetKeysDialog.GetModifiers.<locals>.<listcomp>c             S   s   g | ]}|r|qS r#   r#   )r]   modr#   r#   r$   r^      s    )r   )r    ZmodListr#   r#   r$   rX      s    zGetKeysDialog.GetModifiersc             C   sF   | j jdt | j jtd x| jD ]}|jd q$W | jjd d S )Nr   z0.0r   )rI   Zselect_clearENDrL   ZMOVETOr   r   r   )r    r"   r#   r#   r$   rN      s
    zGetKeysDialog.ClearKeySeqc             C   sn   d| _ ttjtj | _td| _d| _d| _d| _	| j| j | j  | j | j | j	 }| j
jtf|  d S ) 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)ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   rl   )rm   rn   ro   )rp   rq   rr   )rs   rt   ru   rv   rw   rx   ry   rz   )functionKeystuplestringascii_lowercaseZdigitsZalphanumKeysZpunctuationKeysZwhitespaceKeysZeditKeysmoveKeysrI   insertr`   )r    keysr#   r#   r$   r      s     
 $zGetKeysDialog.LoadFinalKeyListc          $   C   s   ddddddddd	d
dddddddddddddddddddddd d!d"d#d$#}||kr\|| }d%|krv|t jkrv|j }d&| }|S )'z2Translate from keycap symbol to the Tkinter keysymZspaceZ
asciitildeZexclamZatZ
numbersignZpercentZasciicircumZ	ampersandZasteriskZ	parenleftZ
parenrightZ
underscoreZminusZplusZequalZ	braceleftZ
bracerightZbracketleftZbracketrightZbarZ	semicolonZcolonZcommaZperiodZlessZgreaterZslashZquestionZPriorZNextZLeftZRightZUpZDownrm   )#rn   ~!@#%^&r   ()_rV   +={}[]|;:,.rU   rW   /?zPage Upz	Page Downz
Left ArrowzRight ArrowzUp Arrowz
Down Arrowrm   rQ   zKey-)r}   r~   upper)r    keyr   ZtranslateDictr#   r#   r$   rZ      s     

zGetKeysDialog.TranslateKeyNc             C   s\   | j j j }|s(| j| j| dd d S | js8| j|rH| j|rH|| _| j	  | j
  d S )NzNo key specified.)r   r   message)r   rG   stripr%   keyerror_titler   KeysOKbind_okr   grab_releasedestroy)r    rT   r   r#   r#   r$   r,      s    
zGetKeysDialog.OKc             C   s   d| _ | j  | j  d S )Nr   )r   r   r   )r    rT   r#   r#   r$   r      s    zGetKeysDialog.Cancelc             C   s   | j jt}| j }d}| j}dd | jD }|jdsJ| j|| dd n~| rr|| j| j	 krr| j|| dd nV|d	gkr|| j| j	 d krd}| j|| |d n"||krd}| j|| |d nd}|S )zValidity check on user's 'basic' keybinding selection.

        Doesn't check the string produced by the advanced dialog because
        'modifiers' isn't set.

        Fc             S   s   g | ]}|D ]}|qqS r#   r#   )r]   Zkeylistr   r#   r#   r$   r^     s    z(GetKeysDialog.KeysOK.<locals>.<listcomp>rW   zMissing the final Key)r   r   zNo modifier key(s) specified.)r   r   r   rQ   rm   rn   zBThe shift modifier by itself may not be used with this key symbol.z'This key combination is already in use.T)rm   rn   )
rI   rG   rY   rX   r   r   endswithr%   r{   r   )r    r   r\   r   ZkeysOKr   Zkey_sequencesmsgr#   r#   r$   r      s,    



zGetKeysDialog.KeysOKc             C   sb   y| j |dd }W n8 tk
rL } z| j| j| d| d dS d}~X nX | j|| dS dS )z:Return True if Tcl accepts the new keys else show message.c               S   s   d S )Nr#   r#   r#   r#   r$   <lambda>  s    z'GetKeysDialog.bind_ok.<locals>.<lambda>z2The entered key sequence is not accepted.

Error: )r   r   r   FNT)rJ   ZTclErrorr%   r   Zunbind)r    r   Zbindingerrr#   r#   r$   r     s    zGetKeysDialog.bind_ok)N)N)__name__
__module____qualname__r   r   r%   r   r   rB   rK   rH   rX   rN   r   rZ   r,   r   r   r   r#   r#   r#   r$   r      s    -O

!r   __main__)mainz!idlelib.idle_test.test_config_keyr   F)	verbosityexit)run)__doc__ZtkinterZtkinter.ttkr   r   r}   rR   r   r   r   Zunittestr   Zidlelib.idle_test.htestr   r#   r#   r#   r$   <module>   s     