mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
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:
parent
c61c170b41
commit
7e55db2bc5
3 changed files with 30 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue