From 280aace067e7df3b706c09e27b044dfea3bacaff Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Fri, 25 Jul 2014 01:56:24 -0400 Subject: Issue #22053: Make help work, after previous patch for this issue disabled it by removing global 'demo'. Refactor and remove duplicate code. --- Lib/turtledemo/__main__.py | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/Lib/turtledemo/__main__.py b/Lib/turtledemo/__main__.py index 0c151a3..92b6186 100755 --- a/Lib/turtledemo/__main__.py +++ b/Lib/turtledemo/__main__.py @@ -27,17 +27,11 @@ def getExampleEntries(): return [entry[:-3] for entry in os.listdir(demo_dir) if entry.endswith(".py") and entry[0] != '_'] -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): @@ -177,12 +171,10 @@ class DemoWindow(object): 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 -- cgit v0.12 From 5c1b8f3de65f8625a90aabef37af9323b2270413 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Fri, 25 Jul 2014 03:06:32 -0400 Subject: Issue #22061: remove call of useless function slated for removal. --- Lib/turtledemo/__main__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/turtledemo/__main__.py b/Lib/turtledemo/__main__.py index 92b6186..c933ea1 100755 --- a/Lib/turtledemo/__main__.py +++ b/Lib/turtledemo/__main__.py @@ -49,7 +49,6 @@ class DemoWindow(object): self.mBar = Frame(root, relief=RAISED, borderwidth=2) self.ExamplesBtn = self.makeLoadDemoMenu() self.OptionsBtn = self.makeHelpMenu() - self.mBar.tk_menuBar(self.ExamplesBtn, self.OptionsBtn) self.mBar.grid(row=0, columnspan=4, sticky='news') pane = PanedWindow(orient=HORIZONTAL, sashwidth=5, -- cgit v0.12