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.
This commit is contained in:
Terry Jan Reedy 2014-07-28 22:23:59 -04:00
parent c61c170b41
commit 7e55db2bc5
3 changed files with 30 additions and 0 deletions

View file

@ -40,6 +40,22 @@ class DemoWindow(object):
root.title('Python turtle-graphics examples')
root.wm_protocol("WM_DELETE_WINDOW", self._destroy)
if sys.platform == 'darwin':
import subprocess
# Make sure we are the currently activated OS X application
# so that our menu bar appears.
p = subprocess.Popen(
[
'osascript',
'-e', 'tell application "System Events"',
'-e', 'set frontmost of the first process whose '
'unix id is {} to true'.format(os.getpid()),
'-e', 'end tell',
],
stderr=subprocess.DEVNULL,
stdout=subprocess.DEVNULL,
)
root.grid_rowconfigure(1, weight=1)
root.grid_columnconfigure(0, weight=1)
root.grid_columnconfigure(1, minsize=90, weight=1)