From 7e55db2bc566381bfda3ddcd44c048f0c627880f Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Mon, 28 Jul 2014 22:23:59 -0400 Subject: 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. --- Lib/idlelib/EditorWindow.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Lib/idlelib/EditorWindow.py') diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py index f3df8eacc9..94cf31429d 100644 --- a/Lib/idlelib/EditorWindow.py +++ b/Lib/idlelib/EditorWindow.py @@ -222,6 +222,7 @@ class EditorWindow(object): text.bind("<>", self.flist.close_all_callback) text.bind("<>", self.open_class_browser) text.bind("<>", self.open_path_browser) + text.bind("<>", 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) -- cgit v1.2.1