Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c95e88c

Browse files
committed
Merge with 3.4
2 parents 6b08235 + 7e55db2 commit c95e88c

3 files changed

Lines changed: 30 additions & 0 deletions

File tree

Lib/idlelib/Bindings.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
windows.
99
1010
"""
11+
from importlib.util import find_spec
12+
1113
from idlelib.configHandler import idleConf
1214

1315
# Warning: menudefs is altered in macosxSupport.overrideRootMenu()
@@ -86,4 +88,7 @@
8688
]),
8789
]
8890

91+
if find_spec('turtledemo'):
92+
menudefs[-1][1].append(('Turtle Demo', '<<open-turtle-demo>>'))
93+
8994
default_keydefs = idleConf.GetCurrentKeySet()

Lib/idlelib/EditorWindow.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ def __init__(self, flist=None, filename=None, key=None, root=None):
222222
text.bind("<<close-all-windows>>", self.flist.close_all_callback)
223223
text.bind("<<open-class-browser>>", self.open_class_browser)
224224
text.bind("<<open-path-browser>>", self.open_path_browser)
225+
text.bind("<<open-turtle-demo>>", self.open_turtle_demo)
225226

226227
self.set_status_bar()
227228
vbar['command'] = text.yview
@@ -705,6 +706,14 @@ def open_path_browser(self, event=None):
705706
from idlelib import PathBrowser
706707
PathBrowser.PathBrowser(self.flist)
707708

709+
def open_turtle_demo(self, event = None):
710+
import subprocess
711+
712+
cmd = [sys.executable,
713+
'-c',
714+
'from turtledemo.__main__ import main; main()']
715+
p = subprocess.Popen(cmd, shell=False)
716+
708717
def gotoline(self, lineno):
709718
if lineno is not None and lineno > 0:
710719
self.text.mark_set("insert", "%d.0" % lineno)

Lib/turtledemo/__main__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,22 @@ def __init__(self, filename=None):
112112
root.title('Python turtle-graphics examples')
113113
root.wm_protocol("WM_DELETE_WINDOW", self._destroy)
114114

115+
if sys.platform == 'darwin':
116+
import subprocess
117+
# Make sure we are the currently activated OS X application
118+
# so that our menu bar appears.
119+
p = subprocess.Popen(
120+
[
121+
'osascript',
122+
'-e', 'tell application "System Events"',
123+
'-e', 'set frontmost of the first process whose '
124+
'unix id is {} to true'.format(os.getpid()),
125+
'-e', 'end tell',
126+
],
127+
stderr=subprocess.DEVNULL,
128+
stdout=subprocess.DEVNULL,
129+
)
130+
115131
root.grid_rowconfigure(1, weight=1)
116132
root.grid_columnconfigure(0, weight=1)
117133
root.grid_columnconfigure(1, minsize=90, weight=1)

0 commit comments

Comments
 (0)