ó
9a^c           @   s°   d  Z  d d l Z d d l Z d d l m Z d d l Z d „  Z d „  Z d a	 d „  Z
 d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d S(   s5   
A number of functions that enhance IDLE on Mac OSX.
iÿÿÿÿN(   t   pathc           C   s   t  j d t d d ƒt ƒ  S(   Ns/   runningAsOSXApp() is deprecated, use isAquaTk()t
   stackleveli   (   t   warningst   warnt   DeprecationWarningt   isAquaTk(    (    (    s&   lib/python2.7/idlelib/macosxSupport.pyt   runningAsOSXApp   s    	c         C   s   t  j d t d d ƒt ƒ  S(   Ns4   isCarbonAquaTk(root) is deprecated, use isCarbonTk()R   i   (   R   R   R   t
   isCarbonTk(   t   root(    (    s&   lib/python2.7/idlelib/macosxSupport.pyt   isCarbonAquaTk   s    	c         C   sˆ   t  j d k r~ |  j j d d ƒ } d | k r9 d a q„ d | k rN d a q„ d |  j j d	 d
 d ƒ k ru d a q„ d a n d a d S(   sl   
    Initializes OS X Tk variant values for
    isAquaTk(), isCarbonTk(), isCocoaTk(), and isXQuartz().
    t   darwint   tkt   windowingsystemt   x11t   xquartzt   aquat   othert   AppKitt   winfot   servert   .t   cocoat   carbonN(   t   syst   platformR   t   callt   _tk_type(   R   t   ws(    (    s&   lib/python2.7/idlelib/macosxSupport.pyt   _initializeTkVariantTests   s    				c           C   s(   t  d k	 s t ‚ t  d k p' t  d k S(   sK   
    Returns True if IDLE is using a native OS X Tk (Cocoa or Carbon).
    R   R   N(   R   t   Nonet   AssertionError(    (    (    s&   lib/python2.7/idlelib/macosxSupport.pyR   *   s    c           C   s   t  d k	 s t ‚ t  d k S(   sb   
    Returns True if IDLE is using a Carbon Aqua Tk (instead of the
    newer Cocoa Aqua Tk).
    R   N(   R   R   R   (    (    (    s&   lib/python2.7/idlelib/macosxSupport.pyR   1   s    c           C   s   t  d k	 s t ‚ t  d k S(   s8   
    Returns True if IDLE is using a Cocoa Aqua Tk.
    R   N(   R   R   R   (    (    (    s&   lib/python2.7/idlelib/macosxSupport.pyt	   isCocoaTk9   s    c           C   s   t  d k	 s t ‚ t  d k S(   s7   
    Returns True if IDLE is using an OS X X11 Tk.
    R   N(   R   R   R   (    (    (    s&   lib/python2.7/idlelib/macosxSupport.pyt	   isXQuartz@   s    c         C   sC   t  ƒ  r; |  j j d d ƒ } | d k r. t Sd j | ƒ St Sd S(   s2  
    Returns a string warning message if the Tk version in use appears to
    be one known to cause problems with IDLE.
    1. Apple Cocoa-based Tk 8.5.7 shipped with Mac OS X 10.6 is unusable.
    2. Apple Cocoa-based Tk 8.5.9 in OS X 10.7 and 10.8 is better but
        can still crash unexpectedly.
    t   infot
   patchlevels   8.5.7s   8.5.9s†   WARNING: The version of Tcl/Tk ({0}) in use may be unstable.\nVisit http://www.python.org/download/mac/tcltk/ for current information.N(   s   8.5.7s   8.5.9(   R   R   R   t   Falset   format(   R   R"   (    (    s&   lib/python2.7/idlelib/macosxSupport.pyt   tkVersionWarningG   s    		c            s#   ‡  f d †  } |  j  d | ƒ d S(   s¢   
    This ensures that the application will respond to open AppleEvents, which
    makes is feasible to use IDLE as the default application for python files.
    c             s"   x |  D] } ˆ  j  | ƒ q Wd  S(   N(   t   open(   t   argst   fn(   t   flist(    s&   lib/python2.7/idlelib/macosxSupport.pyt
   doOpenFile`   s    s   ::tk::mac::OpenDocumentN(   t   createcommand(   R   R)   R*   (    (   R)   s&   lib/python2.7/idlelib/macosxSupport.pyt   addOpenEventSupport[   s    c         C   s2   y |  j  j d d ƒ Wn t j k
 r- n Xd  S(   Nt   consolet   hide(   R   R   t   Tkintert   TclError(   R   (    (    s&   lib/python2.7/idlelib/macosxSupport.pyt   hideTkConsolei   s    c            s¢  d d l  m } d d l m } d d l m ‰  | j d d d } | j d d d 3| j d d j d	 | ƒ | j d d d d
 5| j d d d =| ˆ ƒ } ˆ j d | ƒ i  } | | d d d d ƒ| d <} | j d d d | d d ƒ | ‡  f d † } ˆ  j	 | ƒ d' ‡ f d † }	 d' ‡ ‡ f d † }
 d' ‡ f d † } ˆ j d |	 ƒ ˆ j d |
 ƒ ˆ j d |
 ƒ ˆ r®ˆ j d ˆ j ƒ ˆ j d ˆ j ƒ n  t ƒ  r`| | d d d d ƒ| d <} | j d d d | ƒ | j j d d d( d' g f ƒ ˆ j j d ƒ } t t t | j d  ƒ ƒ ƒ d) k  r`| j d d j d* ƒ q`n  t ƒ  ržˆ j d% |	 ƒ ˆ j d& | ƒ | j d d d =n  d' S(+   sf   
    Replace the Tk root menu by something that is more appropriate for
    IDLE with an Aqua Tk.
    iÿÿÿÿ(   t   Menu(   t   Bindings(   t
   WindowListi    i   iþÿÿÿiýÿÿÿi   i   t   menut   namet   windowst   tearofft   labelt   Windowt	   underlinec            sT   |  j  d ƒ } | d  k r$ d } n  | d k rC |  j d | ƒ n  ˆ  j |  ƒ d  S(   Nt   endiÿÿÿÿi    (   t   indexR   t   deletet   add_windows_to_menu(   R5   R<   (   R4   (    s&   lib/python2.7/idlelib/macosxSupport.pyt   postwindowsmenu™   s    	c            s$   d d l  m } | j ˆ  d ƒ d S(   s   Handle Help 'About IDLE' event.iÿÿÿÿ(   t   aboutDialogs
   About IDLEN(   t   idlelibRA   t   AboutDialog(   t   eventRA   (   R   (    s&   lib/python2.7/idlelib/macosxSupport.pyt   about_dialog£   s    c            s0   d d l  m } ˆ  j ˆ _ | j ˆ d ƒ d S(   s&   Handle Options 'Configure IDLE' event.iÿÿÿÿ(   t   configDialogt   SettingsN(   RB   RF   t   inversedictt   instance_dictt   ConfigDialog(   RD   RF   (   R)   R   (    s&   lib/python2.7/idlelib/macosxSupport.pyt   config_dialog©   s    c            s!   d d l  m } | j ˆ  ƒ d S(   s   Handle Help 'IDLE Help' event.iÿÿÿÿ(   t   helpN(   RB   RL   t   show_idlehelp(   RD   RL   (   R   (    s&   lib/python2.7/idlelib/macosxSupport.pyt   help_dialog°   s    s   <<about-idle>>s   <<open-config-dialog>>s   ::tk::mac::ShowPreferencess   <<close-all-windows>>t   exitt   applet   applicationt   IDLEs
   About IDLEs   info patchlevelR   i   i   i   s   _Preferences....t   tkAboutDialogs   ::tk::mac::ShowHelpN(   s
   About IDLEs   <<about-idle>>(   i   i   i   (   s   _Preferences....s   <<open-config-dialog>>(   R/   R2   RB   R3   R4   t   menudefst   insertt	   configuret   add_cascadet   register_callbackR   t   bindR+   t   close_all_callbackR   R   t   evalt   tuplet   mapt   intt   splitt   appendR   (   R   R)   R2   R3   t	   closeItemt   menubart   menudictR5   R@   RE   RK   RN   t	   tkversion(    (   R4   R)   R   s&   lib/python2.7/idlelib/macosxSupport.pyt   overrideRootMenup   sP     	$	c         C   s>   t  |  ƒ t ƒ  r: t |  ƒ t |  | ƒ t |  | ƒ n  d S(   sì  
    Perform initial OS X customizations if needed.
    Called from PyShell.main() after initial calls to Tk()

    There are currently three major versions of Tk in use on OS X:
        1. Aqua Cocoa Tk (native default since OS X 10.6)
        2. Aqua Carbon Tk (original native, 32-bit only, deprecated)
        3. X11 (supported by some third-party distributors, deprecated)
    There are various differences among the three that affect IDLE
    behavior, primarily with menus, mouse key events, and accelerators.
    Some one-time customizations are performed here.
    Others are dynamically tested throughout idlelib by calls to the
    isAquaTk(), isCarbonTk(), isCocoaTk(), isXQuartz() functions which
    are initialized here as well.
    N(   R   R   R1   Re   R,   (   R   R)   (    (    s&   lib/python2.7/idlelib/macosxSupport.pyt   setupAppÙ   s
    
	
(   t   __doc__R   R/   t   osR    R   R   R	   R   R   R   R   R   R   R    R%   R,   R1   Re   Rf   (    (    (    s&   lib/python2.7/idlelib/macosxSupport.pyt   <module>   s"   											i