3
f% @ s d Z ddlmZ ddlZddlmZ ddlZdadd Zdd Z d d
Z
dd Zd
d Zdd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zedkrdd lmZ ed!d"d# dS )$z3
A number of functions that enhance IDLE on macOS.
)
expanduserN)platformc C sj t dkrbtj } | jjdd}d|kr,dan,d|kr:dand| jjd d
dkrTdand
a| j ndadS )zl
Initializes OS X Tk variant values for
isAquaTk(), isCarbonTk(), isCocoaTk(), and isXQuartz().
darwintkZwindowingsystemZx11xquartzZaquaotherZAppKitZwinfoZserver.cocoacarbonN)r tkinterZTkr call_tk_typeZdestroy)rootZws r 3/opt/alt/python36/lib64/python3.6/idlelib/macosx.py
_init_tk_type s
r c C s t s
t t dkpt dkS )zK
Returns True if IDLE is using a native OS X Tk (Cocoa or Carbon).
r r
)r
r r r r r isAquaTk% s r c C s t s
t t dkS )zb
Returns True if IDLE is using a Carbon Aqua Tk (instead of the
newer Cocoa Aqua Tk).
r
)r
r r r r r
isCarbonTk- s r c C s t s
t t dkS )z8
Returns True if IDLE is using a Cocoa Aqua Tk.
r )r
r r r r r isCocoaTk6 s r c C s t s
t t dkS )z7
Returns True if IDLE is using an OS X X11 Tk.
r )r
r r r r r isXQuartz> s r c C s2 t r*| jjdd}|dkr dS dj|S dS dS ) a2
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.
info
patchlevel8.5.78.5.9FzWARNING: The version of Tcl/Tk ({0}) in use may be unstable.
Visit http://www.python.org/download/mac/tcltk/ for current information.N)r r )r r r format)r r r r r tkVersionWarningG s r c C sN t dkrdS td} y t| d}tj|S Q R X W n tk
rH dS X dS )z-
Fetch the macOS system preferences.
r Nz.~/Library/Preferences/.GlobalPreferences.plistrb)r r openplistlibloadOSError)Z
plist_pathZ
plist_filer r r readSystemPreferences\ s r! c C s, t dkrdS t } | r(| jddkr(dS dS )zJ
Warn if "Prefer tabs when opening documents" is set to "Always".
r NZAppleWindowTabbingModealwayszWARNING: The system preference "Prefer tabs when opening documents" is set to "Always". This will cause various problems with IDLE. For the best experience, change this setting when running IDLE (via System Preferences -> Dock).)r r! get)Zprefsr r r preferTabsPreferenceWarningk s r$ c s fdd}| j d| dS )z
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 | qW d S )N)r )argsfn)flistr r
doOpenFile s
z'addOpenEventSupport.