ó
Š]c           @   sw   d  Z  d d l Td d l Z d d l Z d d l Z d e f d „  ƒ  YZ e d k rs d d l m	 Z	 e	 e ƒ n  d S(   s6   
Dialog for building Tkinter accelerator key bindings
iÿÿÿÿ(   t   *Nt   GetKeysDialogc           B   s†   e  Z e d  „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d	 „  Z d d
 „ Z d d „ Z d „  Z RS(   c         C   s°  t  j |  | ƒ |  j d d ƒ |  j d t d t ƒ |  j | ƒ |  j | ƒ |  j ƒ  |  j d |  j	 ƒ | |  _
 | |  _ | |  _ d |  _ t |  ƒ |  _ |  j j d ƒ |  j ƒ  g  |  _ x: |  j D]/ } t |  ƒ } | j d ƒ |  j j | ƒ qÍ Wt |  _ |  j ƒ  |  j ƒ  |  j ƒ  |  j ƒ  |  j d | j ƒ  | j ƒ  d |  j ƒ  d | j ƒ  | sŒ| j  ƒ  d |  j! ƒ  d n d	 f ƒ |  j" ƒ  |  j# ƒ  d
 S(   s3  
        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
        _htest - bool, change box location when running htest
        t   borderwidthi   t   heightt   widtht   WM_DELETE_WINDOWt    s   +%d+%di   i–   N($   t   Toplevelt   __init__t	   configuret	   resizablet   FALSEt   titlet	   transientt   grab_sett   protocolt   Cancelt   parentt   actiont   currentKeySequencest   resultt	   StringVart	   keyStringt   sett   SetModifiersForPlatformt   modifier_varst	   modifierst   appendt   Falset   advancedt   CreateWidgetst   LoadFinalKeyListt   withdrawt   update_idletaskst   geometryt   winfo_rootxt   winfo_widtht   winfo_reqwidtht   winfo_rootyt   winfo_heightt   winfo_reqheightt	   deiconifyt   wait_window(   t   selfR   R   R   R   t   _htestt   modifiert   variable(    (    s)   lib/python2.7/idlelib/keybindingDialog.pyR   
   s@    
				
		



		0
c         C   sZ  t  |  d d d t ƒ} | j d t d t d t ƒ t  |  ƒ } | j d t d t ƒ t | d d d	 d
 d |  j	 ƒ|  _
 |  j
 j d d d d d d d d ƒ t | d d d	 d
 d |  j ƒ|  _ |  j j d d d d d d d d ƒ t  | ƒ |  _ t  | ƒ |  _ t  | ƒ |  _ t  | ƒ |  _ |  j j d d d d d t d d d d ƒ |  j j d d d d d t d d d d ƒ |  j j ƒ  |  j j d d d d d t d d ƒ |  j j d d d d d t d d ƒ |  j j ƒ  t | d |  j d d ƒ|  _ |  j j d d d d d t d d d d ƒ t |  j d d |  j d ƒ} | j d t ƒ t |  j d t d |  j d t d d ƒ} | j d d d d d t ƒ i  |  _ d } x¡ t |  j |  j  ƒ D]Š \ } } |  j! j" | | ƒ } t# |  j d |  j$ d | d | d | d  d! ƒ}	 |	 j d d d | d d d t ƒ |	 |  j | <| d 7} qÂWt |  j d t d d" d# d$ d% d& d' ƒ}
 |
 j d d d d d( d) d d d t ƒ t% |  j d	 d* d+ d, d- t& ƒ|  _' |  j' j( d. |  j) ƒ |  j' j d d d d) d/ d) d t* ƒ t+ |  j d0 t, d |  j' j- ƒ} |  j' j. d1 | j/ ƒ | j d d d d d/ d) d t* ƒ t |  j d d2 d |  j0 ƒ|  _1 |  j1 j d d d d d( d) ƒ t |  j d t d d3 |  j d4 d5 ƒ} | j d t ƒ t2 |  j d |  j ƒ|  _3 |  j3 j d t ƒ t |  j d t d d6 d7 d8 d9 d: d; d< ƒ} | j d d d d d t ƒ d  S(=   NR   i   t   relieft   sidet   expandt   fillt   textt   OKR   i   t   commandt   rowi    t   columnt   padxi   t   padyR   i   t   stickys   Advanced Key Binding Entry >>t   sticks   New keys for  's   ' :t   anchort   justifyt   textvariablet   ipadxt   ipadyR.   t   onvaluet   offvalueR   s!   Select the desired modifier keys
s"   above, and the final key from the
s   list on the right.

s"   Use upper case Symbols when using
s&   the Shift modifier.  (Letters will be
s   converted automatically.)t
   columnspani   i   R   i
   t
   selectmodes   <ButtonRelease-1>t   rowspant   orientt   yscrollcommands
   Clear Keyss   Enter new binding(s) for  's   ' :
s2   (These bindings will not be checked for validity!)s4   Key bindings are specified using Tkinter keysyms as
sŸ   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!

s8   'Emacs style' multi-keystroke bindings are specified as
s5   follows: <Control-x><Control-y>, where the first key
s!   is the 'do-nothing' keybinding.

s4   Multiple separate bindings for one action should be
s,   separated by a space, eg., <Alt-v> <Meta-v>.(4   t   Framet   SUNKENt   packt   TOPt   TRUEt   BOTHt   BOTTOMt   Xt   ButtonR4   t   buttonOKt   gridR   t   buttonCancelt   frameKeySeqBasict   frameKeySeqAdvancedt   frameControlsBasict   frameHelpAdvancedt   NSEWt   liftt   ToggleLevelt   buttonLevelt   EWt   LabelR   t   Wt   LEFTR   t   GROOVEt   modifier_checkbuttonst   zipR   R   t   modifier_labelt   gett   Checkbuttont   BuildKeyStringt   Listboxt   SINGLEt   listKeysFinalt   bindt   FinalKeySelectedt   NSt	   Scrollbart   VERTICALt   yviewt   configR   t   ClearKeySeqt   buttonCleart   Entryt   entryKeysAdvanced(   R+   t	   frameMaint   frameButtonst   labelTitleBasict   labelKeysBasicR7   R-   R.   t   labelt   checkt   labelFnAdvicet   scrollKeysFinalt   labelTitleAdvancedt   labelHelpAdvanced(    (    s)   lib/python2.7/idlelib/keybindingDialog.pyR   5   s‚    %%++%%+	"	"
(%"

c         C   sM   t  j d k r' d d d d g |  _ n d d d g |  _ i d d 6|  _ d S(	   sU  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.
        t   darwint   Shiftt   Controlt   Optiont   Commandt   Altt   CtrlN(   t   syst   platformR   Rc   (   R+   (    (    s)   lib/python2.7/idlelib/keybindingDialog.pyR   „   s    c         C   s°   |  j  j d ƒ d  d k rl |  j ƒ  |  j  j d d ƒ |  j j ƒ  |  j j ƒ  |  j j ƒ  t	 |  _
 n@ |  j ƒ  |  j  j d d ƒ |  j j ƒ  |  j j ƒ  t |  _
 d  S(   NR3   i   t   Advanceds   << Basic Key Binding Entrys   Advanced Key Binding Entry >>(   R[   t   cgetRq   Rp   RU   RY   RW   Rt   t	   focus_sett   TrueR   RT   RV   R   (   R+   (    (    s)   lib/python2.7/idlelib/keybindingDialog.pyRZ   ’   s    

c         C   s   |  j  ƒ  d  S(   N(   Rf   (   R+   t   event(    (    s)   lib/python2.7/idlelib/keybindingDialog.pyRk   ¡   s    c         C   sr   |  j  ƒ  } } |  j j t ƒ } | rJ |  j | | ƒ } | j | ƒ n  |  j j d t j	 | d ƒ d ƒ d  S(   Nt   <t   -t   >(
   t   GetModifiersRi   Rd   t   ANCHORt   TranslateKeyR   R   R   t   stringt   join(   R+   t   keyListR   t   finalKey(    (    s)   lib/python2.7/idlelib/keybindingDialog.pyRf   ¤   s    c         C   s?   g  |  j  D] } | j ƒ  ^ q
 } g  | D] } | r) | ^ q) S(   N(   R   Rd   (   R+   R.   t   modListt   mod(    (    s)   lib/python2.7/idlelib/keybindingDialog.pyR   ¬   s    "c         C   s[   |  j  j d t ƒ |  j  j t d ƒ x |  j D] } | j d ƒ q0 W|  j j d ƒ d  S(   Ni    s   0.0R   (   Ri   t   select_cleart   ENDRo   t   MOVETOR   R   R   (   R+   R.   (    (    s)   lib/python2.7/idlelib/keybindingDialog.pyRq   °   s
    c         C   s   d |  _  t t j t j ƒ |  _ t d ƒ |  _ d |  _ d |  _ d |  _	 |  j |  j |  j  |  j |  j |  j	 } |  j
 j t | Œ d  S(   Nt   F1t   F2t   F4t   F5t   F6t   F7t   F8t   F9t   F10t   F11t   F12s   ~!@#%^&*()_-+={}[]|;:,.<>/?t   Tabt   Spacet   Returnt	   BackSpacet   Deletet   Insertt   Homet   Ends   Page Ups	   Page Downs
   Left Arrows   Right Arrows   Up Arrows
   Down Arrow(   Rœ   R   R   Rž   RŸ   R    R¡   R¢   R£   R¤   R¥   R¦   (   R§   R¨   R©   (   Rª   R«   R¬   (   R­   R®   s   Page Ups	   Page Downs
   Left Arrows   Right Arrows   Up Arrows
   Down Arrow(   t   functionKeyst   tupleR“   t   ascii_lowercaset   digitst   alphanumKeyst   punctuationKeyst   whitespaceKeyst   editKeyst   moveKeysRi   t   insertRš   (   R+   t   keys(    (    s)   lib/python2.7/idlelib/keybindingDialog.pyR   ·   s     			 	,c         C   sR  i# d d 6d d 6d d 6d d 6d	 d
 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d  6d! d" 6d# d$ 6d% d& 6d' d( 6d) d* 6d+ d, 6d- d. 6d/ d0 6d1 d2 6d3 d4 6d5 d6 6d7 d8 6d9 d: 6d; d< 6d= d> 6d? d@ 6dA dB 6dC dD 6dE dE 6} | | j  ƒ  k r| | } n  dF | k rD| t j k rD| j ƒ  } n  dG | } | S(H   s2   Translate from keycap symbol to the Tkinter keysymt   spaceR¨   t
   asciitildet   ~t   exclamt   !t   att   @t
   numbersignt   #t   percentt   %t   asciicircumt   ^t	   ampersandt   &t   asteriskR    t	   parenleftt   (t
   parenrightt   )t
   underscoret   _t   minusRŽ   t   plust   +t   equalt   =t	   braceleftt   {t
   bracerightt   }t   bracketleftt   [t   bracketrightt   ]t   bart   |t	   semicolont   ;t   colont   :t   commat   ,t   periodt   .t   lessR   t   greaterR   t   slasht   /t   questiont   ?t   Priors   Page Upt   Nexts	   Page Downt   Lefts
   Left Arrowt   Rights   Right Arrowt   Ups   Up Arrowt   Downs
   Down ArrowR§   R€   s   Key-(   R¹   R“   R±   t   upper(   R+   t   keyR   t   translateDict(    (    s)   lib/python2.7/idlelib/keybindingDialog.pyR’   Æ   s     
#
c         C   sB   |  j  s |  j ƒ  r> |  j j ƒ  |  _ |  j ƒ  |  j ƒ  n  d  S(   N(   R   t   KeysOKR   Rd   R   t   grab_releaset   destroy(   R+   RŒ   (    (    s)   lib/python2.7/idlelib/keybindingDialog.pyR4   Ù   s    
c         C   s!   d |  _  |  j ƒ  |  j ƒ  d  S(   NR   (   R   R÷   Rø   (   R+   RŒ   (    (    s)   lib/python2.7/idlelib/keybindingDialog.pyR   ß   s    	
c         C   sj  |  j  j ƒ  } | j ƒ  |  j j t ƒ } |  j ƒ  } | j ƒ  } t } d } | st t j	 d | d |  d d ƒ nò | j
 d ƒ s¢ t j	 d | d |  d d ƒ nÄ | rÞ | |  j |  j k rÞ t j	 d | d |  d d ƒ nˆ | d	 g k r,| |  j |  j d k r,d } t j	 d | d |  d | ƒ n: | |  j k r`d } t j	 d | d |  d | ƒ n t } | S(   s©   Validity check on user's 'basic' keybinding selection.

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

        s   Key Sequence ErrorR   R   t   messages   No keys specified.R   s   Missing the final Keys   No modifier key(s) specified.R€   R§   R¨   sB   The shift modifier by itself may not be used with this key symbol.s'   This key combination is already in use.(   R§   R¨   (   R   Rd   t   stripRi   R‘   R   t   splitR   t   tkMessageBoxt	   showerrort   endswithR¯   R·   R   R‹   (   R+   R¹   R–   R   t   keySequencet   keysOKR   t   msg(    (    s)   lib/python2.7/idlelib/keybindingDialog.pyRö   ä   s6    



N(   t   __name__t
   __module__R   R   R   R   RZ   Rk   Rf   R   Rq   R   R’   t   NoneR4   R   Rö   (    (    (    s)   lib/python2.7/idlelib/keybindingDialog.pyR   	   s   +	O								t   __main__(   t   run(
   t   __doc__t   TkinterRü   R“   R†   R   R   R  t   idlelib.idle_test.htestR  (    (    (    s)   lib/python2.7/idlelib/keybindingDialog.pyt   <module>   s   
ÿ 