Skip to content

Commit af5a324

Browse files
authored
bpo-44254: On Mac, remove disfunctional colors from turtledemo buttons (GH-26448)
On macOS, tk defers to system setting for button background when in normal state. Give turtledemo button text a color that works on either light or dark background.
1 parent 43cf7c8 commit af5a324

File tree

2 files changed

+30
-16
lines changed

2 files changed

+30
-16
lines changed

Lib/turtledemo/__main__.py

+28-16
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ def getExampleEntries():
124124
)
125125

126126

127-
128127
class DemoWindow(object):
129128

130129
def __init__(self, filename=None):
@@ -171,15 +170,23 @@ def __init__(self, filename=None):
171170
self.output_lbl = Label(root, height= 1, text=" --- ", bg="#ddf",
172171
font=("Arial", 16, 'normal'), borderwidth=2,
173172
relief=RIDGE)
174-
self.start_btn = Button(root, text=" START ", font=btnfont,
175-
fg="white", disabledforeground = "#fed",
176-
command=self.startDemo)
177-
self.stop_btn = Button(root, text=" STOP ", font=btnfont,
178-
fg="white", disabledforeground = "#fed",
179-
command=self.stopIt)
180-
self.clear_btn = Button(root, text=" CLEAR ", font=btnfont,
181-
fg="white", disabledforeground="#fed",
182-
command = self.clearCanvas)
173+
if darwin: # Leave Mac button colors alone - #44254.
174+
self.start_btn = Button(root, text=" START ", font=btnfont,
175+
fg='#00cc22', command=self.startDemo)
176+
self.stop_btn = Button(root, text=" STOP ", font=btnfont,
177+
fg='#00cc22', command=self.stopIt)
178+
self.clear_btn = Button(root, text=" CLEAR ", font=btnfont,
179+
fg='#00cc22', command = self.clearCanvas)
180+
else:
181+
self.start_btn = Button(root, text=" START ", font=btnfont,
182+
fg="white", disabledforeground = "#fed",
183+
command=self.startDemo)
184+
self.stop_btn = Button(root, text=" STOP ", font=btnfont,
185+
fg="white", disabledforeground = "#fed",
186+
command=self.stopIt)
187+
self.clear_btn = Button(root, text=" CLEAR ", font=btnfont,
188+
fg="white", disabledforeground="#fed",
189+
command = self.clearCanvas)
183190
self.output_lbl.grid(row=1, column=0, sticky='news', padx=(0,5))
184191
self.start_btn.grid(row=1, column=1, sticky='ew')
185192
self.stop_btn.grid(row=1, column=2, sticky='ew')
@@ -267,12 +274,17 @@ def update_mousewheel(self, event):
267274
return self.increase_size()
268275

269276
def configGUI(self, start, stop, clear, txt="", color="blue"):
270-
self.start_btn.config(state=start,
271-
bg="#d00" if start == NORMAL else "#fca")
272-
self.stop_btn.config(state=stop,
273-
bg="#d00" if stop == NORMAL else "#fca")
274-
self.clear_btn.config(state=clear,
275-
bg="#d00" if clear == NORMAL else "#fca")
277+
if darwin: # Leave Mac button colors alone - #44254.
278+
self.start_btn.config(state=start)
279+
self.stop_btn.config(state=stop)
280+
self.clear_btn.config(state=clear)
281+
else:
282+
self.start_btn.config(state=start,
283+
bg="#d00" if start == NORMAL else "#fca")
284+
self.stop_btn.config(state=stop,
285+
bg="#d00" if stop == NORMAL else "#fca")
286+
self.clear_btn.config(state=clear,
287+
bg="#d00" if clear == NORMAL else "#fca")
276288
self.output_lbl.config(text=txt, fg=color)
277289

278290
def makeLoadDemoMenu(self, master):
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
On Mac, give turtledemo button text a color that works on both light
2+
or dark background. Programmers cannot control the latter.

0 commit comments

Comments
 (0)