[3.13] gh-128062: Fix the font size and shortcut display of the turtledemo menu (GH-128063) (#128101)

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 e163e8d4e1)

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>
This commit is contained in:
Miss Islington (bot) 2024-12-19 21:47:24 +01:00 committed by GitHub
parent 08f9b7cb2a
commit a0f1f120f2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 10 deletions

View file

@ -107,7 +107,6 @@ RUNNING = 3
DONE = 4 DONE = 4
EVENTDRIVEN = 5 EVENTDRIVEN = 5
menufont = ("Arial", 12, NORMAL)
btnfont = ("Arial", 12, 'bold') btnfont = ("Arial", 12, 'bold')
txtfont = ['Lucida Console', 10, 'normal'] txtfont = ['Lucida Console', 10, 'normal']
@ -299,23 +298,21 @@ class DemoWindow(object):
for entry in getExampleEntries(): for entry in getExampleEntries():
def load(entry=entry): def load(entry=entry):
self.loadfile(entry) self.loadfile(entry)
menu.add_command(label=entry, underline=0, menu.add_command(label=entry, underline=0, command=load)
font=menufont, command=load)
return menu return menu
def makeFontMenu(self, master): def makeFontMenu(self, master):
menu = Menu(master, tearoff=0) menu = Menu(master, tearoff=0)
menu.add_command(label="Decrease (C-'-')", command=self.decrease_size, menu.add_command(label="Decrease", command=self.decrease_size,
font=menufont) accelerator=f"{'Command' if darwin else 'Ctrl'}+-")
menu.add_command(label="Increase (C-'+')", command=self.increase_size, menu.add_command(label="Increase", command=self.increase_size,
font=menufont) accelerator=f"{'Command' if darwin else 'Ctrl'}+=")
menu.add_separator() menu.add_separator()
for size in font_sizes: for size in font_sizes:
def resize(size=size): def resize(size=size):
self.set_txtsize(size) self.set_txtsize(size)
menu.add_command(label=str(size), underline=0, menu.add_command(label=str(size), underline=0, command=resize)
font=menufont, command=resize)
return menu return menu
def makeHelpMenu(self, master): def makeHelpMenu(self, master):
@ -324,7 +321,7 @@ class DemoWindow(object):
for help_label, help_file in help_entries: for help_label, help_file in help_entries:
def show(help_label=help_label, help_file=help_file): def show(help_label=help_label, help_file=help_file):
view_text(self.root, help_label, 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 return menu
def refreshCanvas(self): def refreshCanvas(self):

View file

@ -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.