[issue17172] Add turtledemo to IDLE menu

Terry J. Reedy report at bugs.python.org
Tue Jul 29 02:27:32 CEST 2014


Terry J. Reedy added the comment:

I agree with skipping 2.7. The current patch is based on importing turtledemo, while on 2.7, turtleDemo.py is in Demo/turtle/ and cannot be imported. It could run with execfile, but the viewer will only run if /turtle is the current directory. On Windows, this would still be useless as the 2.7 installer does not install Demo or anything therein. When turtleDemo is installed, the location is system dependent. An extended version of the new checker extension, #21880, would allow users to configure 'run turtledemo' to work on a system that has it.

The patch works fine on Windows, including not blocking other actions with Idle. The only change I might make is
   cmd = [sys.executable, '-m', 'turtledemo']
which is more readable and does the same as the current version. But see below. (Lita, don't make a new patch for this or anything else in this message.)

The main remaining demo viewer fix is font re-sizing, #21933, which I expect we should finish within a week.

'Run turtledemo' should go on the Run menu, along with other 'run <external program>' menu items.  The Run menu is easily enabled in the Shell window by adding '("run", "_Run"),' to menu_specs before options (line 842). However, putting the entry where it would belong, after Run Module, means that the addition has to be delayed until after the ScriptBinding extension is loaded. That would be done most easily as part of loading the checker extension #21880.  The open_turtle_demo function would be moved and perhaps generalized.

The change to make turtledemo run properly in a subprocess on Mac appears to be a separate issue from adding it to Idle's menu. I presume that if turtledemo.__main__ is loaded into Idle, and run with F5, as I have been doing, there is the same problem (on a Mac). I would guess that the same would be true of any tkinter app run in a subprocess from Idle. How about non-gui apps that are not mac-aware? If any of these are true, the fix would be generally useful outside of turtledemo and would seem to belong somewhere in the tkinter package.  (Is the same true for some of maxosxSupport).

If the activate code is moved to macosxSupport.activate(), does the following work in EditorWindow.open_turtle_demo?
cmd = [sys.executable, '-c',
  'from idlelib.macosxSupport import activate as A; A()\n'
  'from turtledemo.__main__ import main; main()']
Does the activate code have to be called after, say, the tkinter import in turtledemo, or is anytime in the process ok?  While something like this is not needed to run turtledemo, which we can edit, it would be to run tkinter (or mac-unaware gui apps) that we cannot edit.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17172>
_______________________________________


More information about the Python-bugs-list mailing list