summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/macosx.py
diff options
context:
space:
mode:
authorTal Einat <taleinat+github@gmail.com>2018-12-07 06:32:21 (GMT)
committerTerry Jan Reedy <tjreedy@udel.edu>2018-12-07 06:32:21 (GMT)
commit9ebe8794f003dadfff578a066ea503a3e37ffe1d (patch)
tree427935bc44f75fac3de05d16ba7d60370b2bb250 /Lib/idlelib/macosx.py
parent16501b70826695991b3a151dfc538f010be5c765 (diff)
downloadcpython-9ebe8794f003dadfff578a066ea503a3e37ffe1d.zip
cpython-9ebe8794f003dadfff578a066ea503a3e37ffe1d.tar.gz
cpython-9ebe8794f003dadfff578a066ea503a3e37ffe1d.tar.bz2
bpo-34864: warn if "Prefer tabs when opening documents" set to "Always" (#10464)
* bpo-34864: warn if "Prefer tabs when opening documents" set to "Always" * add NEWS entry * address code review comments * address second code review comments * Add entry for idlelib/NEWS.txt.
Diffstat (limited to 'Lib/idlelib/macosx.py')
-rw-r--r--Lib/idlelib/macosx.py43
1 files changed, 39 insertions, 4 deletions
diff --git a/Lib/idlelib/macosx.py b/Lib/idlelib/macosx.py
index 8f8484a..9be4ed2 100644
--- a/Lib/idlelib/macosx.py
+++ b/Lib/idlelib/macosx.py
@@ -1,6 +1,8 @@
"""
A number of functions that enhance IDLE on macOS.
"""
+from os.path import expanduser
+import plistlib
from sys import platform # Used in _init_tk_type, changed by test.
import tkinter
@@ -79,14 +81,47 @@ def tkVersionWarning(root):
patchlevel = root.tk.call('info', 'patchlevel')
if patchlevel not in ('8.5.7', '8.5.9'):
return False
- return (r"WARNING: The version of Tcl/Tk ({0}) in use may"
- r" be unstable.\n"
- r"Visit http://www.python.org/download/mac/tcltk/"
- r" for current information.".format(patchlevel))
+ return ("WARNING: The version of Tcl/Tk ({0}) in use may"
+ " be unstable.\n"
+ "Visit http://www.python.org/download/mac/tcltk/"
+ " for current information.".format(patchlevel))
else:
return False
+def readSystemPreferences():
+ """
+ Fetch the macOS system preferences.
+ """
+ if platform != 'darwin':
+ return None
+
+ plist_path = expanduser('~/Library/Preferences/.GlobalPreferences.plist')
+ try:
+ with open(plist_path, 'rb') as plist_file:
+ return plistlib.load(plist_file)
+ except OSError:
+ return None
+
+
+def preferTabsPreferenceWarning():
+ """
+ Warn if "Prefer tabs when opening documents" is set to "Always".
+ """
+ if platform != 'darwin':
+ return None
+
+ prefs = readSystemPreferences()
+ if prefs and prefs.get('AppleWindowTabbingMode') == 'always':
+ return (
+ 'WARNING: 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).'
+ )
+ return None
+
+
## Fix the menu and related functions.
def addOpenEventSupport(root, flist):