Skip to content

Commit e163e8d

Browse files
Xiaokang2022ZeroIntensityterryjreedy
authored
gh-128062: Fix the font size and shortcut display of the turtledemo menu (#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. --------- Co-authored-by: Peter Bierma <[email protected]> Co-authored-by: Terry Jan Reedy <[email protected]>
1 parent 1b15c89 commit e163e8d

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

Lib/turtledemo/__main__.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@
105105
DONE = 4
106106
EVENTDRIVEN = 5
107107

108-
menufont = ("Arial", 12, NORMAL)
109108
btnfont = ("Arial", 12, 'bold')
110109
txtfont = ['Lucida Console', 10, 'normal']
111110

@@ -297,23 +296,21 @@ def makeLoadDemoMenu(self, master):
297296
for entry in getExampleEntries():
298297
def load(entry=entry):
299298
self.loadfile(entry)
300-
menu.add_command(label=entry, underline=0,
301-
font=menufont, command=load)
299+
menu.add_command(label=entry, underline=0, command=load)
302300
return menu
303301

304302
def makeFontMenu(self, master):
305303
menu = Menu(master, tearoff=0)
306-
menu.add_command(label="Decrease (C-'-')", command=self.decrease_size,
307-
font=menufont)
308-
menu.add_command(label="Increase (C-'+')", command=self.increase_size,
309-
font=menufont)
304+
menu.add_command(label="Decrease", command=self.decrease_size,
305+
accelerator=f"{'Command' if darwin else 'Ctrl'}+-")
306+
menu.add_command(label="Increase", command=self.increase_size,
307+
accelerator=f"{'Command' if darwin else 'Ctrl'}+=")
310308
menu.add_separator()
311309

312310
for size in font_sizes:
313311
def resize(size=size):
314312
self.set_txtsize(size)
315-
menu.add_command(label=str(size), underline=0,
316-
font=menufont, command=resize)
313+
menu.add_command(label=str(size), underline=0, command=resize)
317314
return menu
318315

319316
def makeHelpMenu(self, master):
@@ -322,7 +319,7 @@ def makeHelpMenu(self, master):
322319
for help_label, help_file in help_entries:
323320
def show(help_label=help_label, help_file=help_file):
324321
view_text(self.root, help_label, help_file)
325-
menu.add_command(label=help_label, font=menufont, command=show)
322+
menu.add_command(label=help_label, command=show)
326323
return menu
327324

328325
def refreshCanvas(self):
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Revert the font of :mod:`turtledemo`'s menu bar to its default value and
2+
display the shortcut keys in the correct position.

0 commit comments

Comments
 (0)