summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/macosx.py
diff options
context:
space:
mode:
authorTerry Jan Reedy <tjreedy@udel.edu>2016-06-12 19:49:20 (GMT)
committerTerry Jan Reedy <tjreedy@udel.edu>2016-06-12 19:49:20 (GMT)
commit2518fa8326578c0407e45a1397b78cbccd4b55b0 (patch)
tree3c9aef10e02b8cb8c853a97655206086f8fcf6af /Lib/idlelib/macosx.py
parent7670e3c12ec4d0c08db6b9ac82ebd5279b5f9da2 (diff)
downloadcpython-2518fa8326578c0407e45a1397b78cbccd4b55b0.zip
cpython-2518fa8326578c0407e45a1397b78cbccd4b55b0.tar.gz
cpython-2518fa8326578c0407e45a1397b78cbccd4b55b0.tar.bz2
Issue #27239: Continue refactoring idlelib.macosx and adding macosx tests.
Diffstat (limited to 'Lib/idlelib/macosx.py')
-rw-r--r--Lib/idlelib/macosx.py25
1 files changed, 18 insertions, 7 deletions
diff --git a/Lib/idlelib/macosx.py b/Lib/idlelib/macosx.py
index 98d7887..f9f558d 100644
--- a/Lib/idlelib/macosx.py
+++ b/Lib/idlelib/macosx.py
@@ -1,20 +1,24 @@
"""
A number of functions that enhance IDLE on Mac OSX.
"""
-import sys
+from sys import platform # Used in _init_tk_type, changed by test.
import tkinter
import warnings
+
+## Define functions that query the Mac graphics type.
+## _tk_type and its initializer are private to this section.
+
_tk_type = None
-def _init_tk_type(idleroot=None):
+def _init_tk_type():
"""
Initializes OS X Tk variant values for
isAquaTk(), isCarbonTk(), isCocoaTk(), and isXQuartz().
"""
global _tk_type
- if sys.platform == 'darwin':
- root = idleroot or tkinter.Tk()
+ if platform == 'darwin':
+ root = tkinter.Tk()
ws = root.tk.call('tk', 'windowingsystem')
if 'x11' in ws:
_tk_type = "xquartz"
@@ -24,8 +28,7 @@ def _init_tk_type(idleroot=None):
_tk_type = "cocoa"
else:
_tk_type = "carbon"
- if not idleroot:
- root.destroy
+ root.destroy()
else:
_tk_type = "other"
@@ -62,6 +65,7 @@ def isXQuartz():
_init_tk_type()
return _tk_type == "xquartz"
+
def tkVersionWarning(root):
"""
Returns a string warning message if the Tk version in use appears to
@@ -82,6 +86,9 @@ def tkVersionWarning(root):
else:
return False
+
+## Fix the menu and related functions.
+
def addOpenEventSupport(root, flist):
"""
This ensures that the application will respond to open AppleEvents, which
@@ -233,9 +240,13 @@ def setupApp(root, flist):
isAquaTk(), isCarbonTk(), isCocoaTk(), isXQuartz() functions which
are initialized here as well.
"""
- _init_tk_type(root)
if isAquaTk():
hideTkConsole(root)
overrideRootMenu(root, flist)
addOpenEventSupport(root, flist)
fixb2context(root)
+
+
+if __name__ == '__main__':
+ from unittest import main
+ main('idlelib.idle_test.test_macosx', verbosity=2)