diff options
author | Terry Jan Reedy <tjreedy@udel.edu> | 2014-07-25 05:56:17 (GMT) |
---|---|---|
committer | Terry Jan Reedy <tjreedy@udel.edu> | 2014-07-25 05:56:17 (GMT) |
commit | 8ac01bf038a7fe70f9bdb29df625b0cf42aa98ee (patch) | |
tree | 509fb766c5a3abcdc72f66e45cab5a2241bb76b4 /Demo | |
parent | 1d9457d2d29d75a20c2eab7e1570b59ee3306b27 (diff) | |
download | cpython-8ac01bf038a7fe70f9bdb29df625b0cf42aa98ee.zip cpython-8ac01bf038a7fe70f9bdb29df625b0cf42aa98ee.tar.gz cpython-8ac01bf038a7fe70f9bdb29df625b0cf42aa98ee.tar.bz2 |
Issue #22053: Make help work, after previous patch for this issue disabled it
by removing global 'demo'. Refactor and remove duplicate code.
Diffstat (limited to 'Demo')
-rwxr-xr-x | Demo/turtle/turtleDemo.py | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/Demo/turtle/turtleDemo.py b/Demo/turtle/turtleDemo.py index c3b87a2..6f37292 100755 --- a/Demo/turtle/turtleDemo.py +++ b/Demo/turtle/turtleDemo.py @@ -44,17 +44,11 @@ def getExampleEntries(): entries2.append(subdir+scripts) return entries2 -def showDemoHelp(): - view_file(demo.root, "Help on turtleDemo", - os.path.join(demo_dir, "demohelp.txt")) - -def showAboutDemo(): - view_file(demo.root, "About turtleDemo", - os.path.join(demo_dir, "about_turtledemo.txt")) - -def showAboutTurtle(): - view_file(demo.root, "About the new turtle module.", - os.path.join(demo_dir, "about_turtle.txt")) +help_entries = ( # (help_label, help_file) + ('Turtledemo help', "demohelp.txt"), + ('About turtledemo', "about_turtledemo.txt"), + ('About turtle module', "about_turtle.txt"), + ) class DemoWindow(object): @@ -200,18 +194,15 @@ class DemoWindow(object): CmdBtn['menu'] = CmdBtn.menu return CmdBtn - def makeHelpMenu(self): CmdBtn = Menubutton(self.mBar, text='Help', underline=0, font = menufont) CmdBtn.pack(side=LEFT, padx='2m') CmdBtn.menu = Menu(CmdBtn) - CmdBtn.menu.add_command(label='About turtle.py', font=menufont, - command=showAboutTurtle) - CmdBtn.menu.add_command(label='turtleDemo - Help', font=menufont, - command=showDemoHelp) - CmdBtn.menu.add_command(label='About turtleDemo', font=menufont, - command=showAboutDemo) + for help_label, help_file in help_entries: + def show(help_label=help_label, help_file=help_file): + view_file(self.root, help_label, os.path.join(demo_dir, help_file)) + CmdBtn.menu.add_command(label=help_label, font=menufont, command=show) CmdBtn['menu'] = CmdBtn.menu return CmdBtn |