[Python-checkins] cpython (2.7): Issue #21824: Turtledemo 2.7 help menu entries now display help text instead

terry.reedy python-checkins at python.org
Sun Jun 22 08:32:42 CEST 2014


http://hg.python.org/cpython/rev/9778d37c2d18
changeset: 91314:9778d37c2d18
branch: 2.7
parent: 91311:a43d03cdf38b
user: Terry Jan Reedy <tjreedy at udel.edu>
date: Sun Jun 22 02:32:26 2014 -0400
summary:
 Issue #21824: Turtledemo 2.7 help menu entries now display help text instead
of help file name.
files:
 Demo/turtle/turtleDemo.py | 26 +++++++++++++++-----------
 1 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/Demo/turtle/turtleDemo.py b/Demo/turtle/turtleDemo.py
--- a/Demo/turtle/turtleDemo.py
+++ b/Demo/turtle/turtleDemo.py
@@ -5,11 +5,17 @@
 from Tkinter import *
 from idlelib.Percolator import Percolator
 from idlelib.ColorDelegator import ColorDelegator
-from idlelib.textView import TextViewer
+from idlelib.textView import view_file
 
 import turtle
 import time
 
+demo_dir = os.getcwd()
+if "turtleDemo.py" not in os.listdir(demo_dir):
+ print "Directory of turtleDemo must be current working directory!"
+ print "But in your case this is", demo_dir
+ sys.exit()
+
 STARTUP = 1
 READY = 2
 RUNNING = 3
@@ -21,12 +27,7 @@
 txtfont = ('Lucida Console', 8, 'normal')
 
 def getExampleEntries():
- cwd = os.getcwd()
- if "turtleDemo.py" not in os.listdir(cwd):
- print "Directory of turtleDemo must be current working directory!"
- print "But in your case this is", cwd
- sys.exit()
- entries1 = [entry for entry in os.listdir(cwd) if
+ entries1 = [entry for entry in os.listdir(demo_dir) if
 entry.startswith("tdemo_") and
 not entry.endswith(".pyc")]
 entries2 = []
@@ -34,7 +35,7 @@
 if entry.endswith(".py"):
 entries2.append(entry)
 else:
- path = os.path.join(cwd,entry)
+ path = os.path.join(demo_dir, entry)
 sys.path.append(path)
 subdir = [entry]
 scripts = [script for script in os.listdir(path) if
@@ -44,13 +45,16 @@
 return entries2
 
 def showDemoHelp():
- TextViewer(demo.root, "Help on turtleDemo", "demohelp.txt")
+ view_file(demo.root, "Help on turtleDemo",
+ os.path.join(demo_dir, "demohelp.txt"))
 
 def showAboutDemo():
- TextViewer(demo.root, "About turtleDemo", "about_turtledemo.txt")
+ view_file(demo.root, "About turtleDemo",
+ os.path.join(demo_dir, "about_turtledemo.txt"))
 
 def showAboutTurtle():
- TextViewer(demo.root, "About the new turtle module", "about_turtle.txt")
+ view_file(demo.root, "About the new turtle module.",
+ os.path.join(demo_dir, "about_turtle.txt"))
 
 class DemoWindow(object):
 
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /