@@ -27,17 +27,11 @@ def getExampleEntries():
2727 return [entry [:- 3 ] for entry in os .listdir (demo_dir ) if
2828 entry .endswith (".py" ) and entry [0 ] != '_' ]
2929
30- def showDemoHelp ():
31- view_file (demo .root , "Help on turtleDemo" ,
32- os .path .join (demo_dir , "demohelp.txt" ))
33-
34- def showAboutDemo ():
35- view_file (demo .root , "About turtleDemo" ,
36- os .path .join (demo_dir , "about_turtledemo.txt" ))
37-
38- def showAboutTurtle ():
39- view_file (demo .root , "About the new turtle module." ,
40- os .path .join (demo_dir , "about_turtle.txt" ))
30+ help_entries = ( # (help_label, help_file)
31+ ('Turtledemo help' , "demohelp.txt" ),
32+ ('About turtledemo' , "about_turtledemo.txt" ),
33+ ('About turtle module' , "about_turtle.txt" ),
34+ )
4135
4236class DemoWindow (object ):
4337
@@ -177,12 +171,10 @@ def makeHelpMenu(self):
177171 CmdBtn .pack (side = LEFT , padx = '2m' )
178172 CmdBtn .menu = Menu (CmdBtn )
179173
180- CmdBtn .menu .add_command (label = 'About turtle.py' , font = menufont ,
181- command = showAboutTurtle )
182- CmdBtn .menu .add_command (label = 'turtleDemo - Help' , font = menufont ,
183- command = showDemoHelp )
184- CmdBtn .menu .add_command (label = 'About turtleDemo' , font = menufont ,
185- command = showAboutDemo )
174+ for help_label , help_file in help_entries :
175+ def show (help_label = help_label , help_file = help_file ):
176+ view_file (self .root , help_label , os .path .join (demo_dir , help_file ))
177+ CmdBtn .menu .add_command (label = help_label , font = menufont , command = show )
186178
187179 CmdBtn ['menu' ] = CmdBtn .menu
188180 return CmdBtn
0 commit comments