Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-44254: On Mac, remove disfunctional colors from turtledemo buttons #26448

Merged
merged 4 commits into from
May 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 28 additions & 16 deletions Lib/turtledemo/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ def getExampleEntries():
)



class DemoWindow(object):

def __init__(self, filename=None):
Expand Down Expand Up @@ -171,15 +170,23 @@ def __init__(self, filename=None):
self.output_lbl = Label(root, height= 1, text=" --- ", bg="#ddf",
font=("Arial", 16, 'normal'), borderwidth=2,
relief=RIDGE)
self.start_btn = Button(root, text=" START ", font=btnfont,
fg="white", disabledforeground = "#fed",
command=self.startDemo)
self.stop_btn = Button(root, text=" STOP ", font=btnfont,
fg="white", disabledforeground = "#fed",
command=self.stopIt)
self.clear_btn = Button(root, text=" CLEAR ", font=btnfont,
fg="white", disabledforeground="#fed",
command = self.clearCanvas)
if darwin: # Leave Mac button colors alone - #44254.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It duplicates a lot of code which is the same on all platforms. Would not be better to factor out variable parts?

if darwin:
    foreground = ...
    disabledforeground = ...
else:
    foreground = ...
    disabledforeground = ...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an interim patch changing Mac only that I hope gets into .0b2 to workaround the tk bug on Mac (see issue). I initially removed both colors for Mac, but the default buttons are buggy depending on the users choice of theme. The default disabled foreground on Mac is fine as far as I know, and I don't especially care as being readable then does not matter. After I decide what to do with non-Mac, I will consider whether to even set disabledforeground on non-Mac. I want to try multiple colors on non-Mac, and if so, the code will not be exactly parallel. And maybe use ttk widgets.

self.start_btn = Button(root, text=" START ", font=btnfont,
fg='#00cc22', command=self.startDemo)
self.stop_btn = Button(root, text=" STOP ", font=btnfont,
fg='#00cc22', command=self.stopIt)
self.clear_btn = Button(root, text=" CLEAR ", font=btnfont,
fg='#00cc22', command = self.clearCanvas)
else:
self.start_btn = Button(root, text=" START ", font=btnfont,
fg="white", disabledforeground = "#fed",
command=self.startDemo)
self.stop_btn = Button(root, text=" STOP ", font=btnfont,
fg="white", disabledforeground = "#fed",
command=self.stopIt)
self.clear_btn = Button(root, text=" CLEAR ", font=btnfont,
fg="white", disabledforeground="#fed",
command = self.clearCanvas)
self.output_lbl.grid(row=1, column=0, sticky='news', padx=(0,5))
self.start_btn.grid(row=1, column=1, sticky='ew')
self.stop_btn.grid(row=1, column=2, sticky='ew')
Expand Down Expand Up @@ -267,12 +274,17 @@ def update_mousewheel(self, event):
return self.increase_size()

def configGUI(self, start, stop, clear, txt="", color="blue"):
self.start_btn.config(state=start,
bg="#d00" if start == NORMAL else "#fca")
self.stop_btn.config(state=stop,
bg="#d00" if stop == NORMAL else "#fca")
self.clear_btn.config(state=clear,
bg="#d00" if clear == NORMAL else "#fca")
if darwin: # Leave Mac button colors alone - #44254.
self.start_btn.config(state=start)
self.stop_btn.config(state=stop)
self.clear_btn.config(state=clear)
else:
self.start_btn.config(state=start,
bg="#d00" if start == NORMAL else "#fca")
self.stop_btn.config(state=stop,
bg="#d00" if stop == NORMAL else "#fca")
self.clear_btn.config(state=clear,
bg="#d00" if clear == NORMAL else "#fca")
self.output_lbl.config(text=txt, fg=color)

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