diff options
author | Terry Jan Reedy <tjreedy@udel.edu> | 2014-07-29 02:23:59 (GMT) |
---|---|---|
committer | Terry Jan Reedy <tjreedy@udel.edu> | 2014-07-29 02:23:59 (GMT) |
commit | 7e55db2bc566381bfda3ddcd44c048f0c627880f (patch) | |
tree | 3cc079e69282249043a7408b26d5bd10c519eeb2 /Lib/turtledemo | |
parent | c61c170b419be5896608baf47ca3737b94cc15da (diff) | |
download | cpython-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/turtledemo')
-rwxr-xr-x | Lib/turtledemo/__main__.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/turtledemo/__main__.py b/Lib/turtledemo/__main__.py index 07560c3..63f97e2 100755 --- a/Lib/turtledemo/__main__.py +++ b/Lib/turtledemo/__main__.py @@ -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) |