summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib
diff options
context:
space:
mode:
authorTerry Jan Reedy <tjreedy@udel.edu>2014-07-29 02:23:59 (GMT)
committerTerry Jan Reedy <tjreedy@udel.edu>2014-07-29 02:23:59 (GMT)
commit7e55db2bc566381bfda3ddcd44c048f0c627880f (patch)
tree3cc079e69282249043a7408b26d5bd10c519eeb2 /Lib/idlelib
parentc61c170b419be5896608baf47ca3737b94cc15da (diff)
downloadcpython-7e55db2bc566381bfda3ddcd44c048f0c627880f.zip
cpython-7e55db2bc566381bfda3ddcd44c048f0c627880f.tar.gz
cpython-7e55db2bc566381bfda3ddcd44c048f0c627880f.tar.bz2
Issue #17172: Add the ability to run turtledemo from Idle.
Make turtledemo start as active on Mac even when run with subprocess. Patch by Ramchandra Apt, Lita Cho, and Ned Daily.
Diffstat (limited to 'Lib/idlelib')
-rw-r--r--Lib/idlelib/Bindings.py5
-rw-r--r--Lib/idlelib/EditorWindow.py9
2 files changed, 14 insertions, 0 deletions
diff --git a/Lib/idlelib/Bindings.py b/Lib/idlelib/Bindings.py
index df2b251..c9bef21 100644
--- a/Lib/idlelib/Bindings.py
+++ b/Lib/idlelib/Bindings.py
@@ -8,6 +8,8 @@ the PythonShell window, and a Format menu which is only present in the Editor
windows.
"""
+from importlib.util import find_spec
+
from idlelib.configHandler import idleConf
# Warning: menudefs is altered in macosxSupport.overrideRootMenu()
@@ -86,4 +88,7 @@ menudefs = [
]),
]
+if find_spec('turtledemo'):
+ menudefs[-1][1].append(('Turtle Demo', '<<open-turtle-demo>>'))
+
default_keydefs = idleConf.GetCurrentKeySet()
diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py
index f3df8ea..94cf314 100644
--- a/Lib/idlelib/EditorWindow.py
+++ b/Lib/idlelib/EditorWindow.py
@@ -222,6 +222,7 @@ class EditorWindow(object):
text.bind("<<close-all-windows>>", self.flist.close_all_callback)
text.bind("<<open-class-browser>>", self.open_class_browser)
text.bind("<<open-path-browser>>", self.open_path_browser)
+ text.bind("<<open-turtle-demo>>", self.open_turtle_demo)
self.set_status_bar()
vbar['command'] = text.yview
@@ -705,6 +706,14 @@ class EditorWindow(object):
from idlelib import PathBrowser
PathBrowser.PathBrowser(self.flist)
+ def open_turtle_demo(self, event = None):
+ import subprocess
+
+ cmd = [sys.executable,
+ '-c',
+ 'from turtledemo.__main__ import main; main()']
+ p = subprocess.Popen(cmd, shell=False)
+
def gotoline(self, lineno):
if lineno is not None and lineno > 0:
self.text.mark_set("insert", "%d.0" % lineno)