]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-128062: Fix the font size and shortcut display of the turtledemo menu ...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 19 Dec 2024 20:47:24 +0000 (21:47 +0100)
committerGitHub <noreply@github.com>
Thu, 19 Dec 2024 20:47:24 +0000 (20:47 +0000)
gh-128062: Fix the font size and shortcut display of the turtledemo menu (GH-128063)

Leave the font of the menu bar the default to keep it consistent with the rest of the world. Display the shortcut keys in the right way, using the 'accelerator' option.
---------

(cherry picked from commit e163e8d4e1a9844b8615ef38b9917b887a377948)

Co-authored-by: Zhikang Yan <2951256653@qq.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Lib/turtledemo/__main__.py
Misc/NEWS.d/next/Library/2024-12-18-10-18-55.gh-issue-128062.E9oU7-.rst [new file with mode: 0644]

index df94ebc10c01e83665eb1d7839f6249a1e8f46b2..8dbda474bb3efd81844461a3857676c0f91889b1 100755 (executable)
@@ -107,7 +107,6 @@ RUNNING = 3
 DONE = 4
 EVENTDRIVEN = 5
 
-menufont = ("Arial", 12, NORMAL)
 btnfont = ("Arial", 12, 'bold')
 txtfont = ['Lucida Console', 10, 'normal']
 
@@ -299,23 +298,21 @@ class DemoWindow(object):
         for entry in getExampleEntries():
             def load(entry=entry):
                 self.loadfile(entry)
-            menu.add_command(label=entry, underline=0,
-                             font=menufont, command=load)
+            menu.add_command(label=entry, underline=0, command=load)
         return menu
 
     def makeFontMenu(self, master):
         menu = Menu(master, tearoff=0)
-        menu.add_command(label="Decrease (C-'-')", command=self.decrease_size,
-                         font=menufont)
-        menu.add_command(label="Increase (C-'+')", command=self.increase_size,
-                         font=menufont)
+        menu.add_command(label="Decrease", command=self.decrease_size,
+                         accelerator=f"{'Command' if darwin else 'Ctrl'}+-")
+        menu.add_command(label="Increase", command=self.increase_size,
+                         accelerator=f"{'Command' if darwin else 'Ctrl'}+=")
         menu.add_separator()
 
         for size in font_sizes:
             def resize(size=size):
                 self.set_txtsize(size)
-            menu.add_command(label=str(size), underline=0,
-                             font=menufont, command=resize)
+            menu.add_command(label=str(size), underline=0, command=resize)
         return menu
 
     def makeHelpMenu(self, master):
@@ -324,7 +321,7 @@ class DemoWindow(object):
         for help_label, help_file in help_entries:
             def show(help_label=help_label, help_file=help_file):
                 view_text(self.root, help_label, help_file)
-            menu.add_command(label=help_label, font=menufont, command=show)
+            menu.add_command(label=help_label, command=show)
         return menu
 
     def refreshCanvas(self):
diff --git a/Misc/NEWS.d/next/Library/2024-12-18-10-18-55.gh-issue-128062.E9oU7-.rst b/Misc/NEWS.d/next/Library/2024-12-18-10-18-55.gh-issue-128062.E9oU7-.rst
new file mode 100644 (file)
index 0000000..d8e262e
--- /dev/null
@@ -0,0 +1,2 @@
+Revert the font of :mod:`turtledemo`'s menu bar to its default value and
+display the shortcut keys in the correct position.