summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib
diff options
context:
space:
mode:
authorJohn Riggles <jriggles@icloud.com>2024-08-02 03:02:43 (GMT)
committerGitHub <noreply@github.com>2024-08-02 03:02:43 (GMT)
commit5a7f7c48644baf82988f30bcb43e03dcfceb75dd (patch)
treed0553f4065cc589e4324b7cd00fb75b20bafb413 /Lib/idlelib
parentdbdbef3668293abdceac2b8a7b3e4615e6bde143 (diff)
downloadcpython-5a7f7c48644baf82988f30bcb43e03dcfceb75dd.zip
cpython-5a7f7c48644baf82988f30bcb43e03dcfceb75dd.tar.gz
cpython-5a7f7c48644baf82988f30bcb43e03dcfceb75dd.tar.bz2
gh-120083: Add IDLE Hovertip foreground color needed for recent macOS (#120605)
On recent versions of macOS (sometime between Catalina and Sonoma 14.5), the default Hovertip foreground color changed from black to white, thereby matching the background. This might be a matter of matching the white foreground of the dark-mode text. The unreadable result is shown here (#120083 (comment)). The foreground and background colors were made parameters so we can pass different colors for future additional hovertips in IDLE. --------- Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Diffstat (limited to 'Lib/idlelib')
-rw-r--r--Lib/idlelib/News3.txt4
-rw-r--r--Lib/idlelib/tooltip.py8
2 files changed, 10 insertions, 2 deletions
diff --git a/Lib/idlelib/News3.txt b/Lib/idlelib/News3.txt
index a7a92e9..37ff93f 100644
--- a/Lib/idlelib/News3.txt
+++ b/Lib/idlelib/News3.txt
@@ -4,6 +4,10 @@ Released on 2024-10-xx
=========================
+gh-120083: Add explicit black IDLE Hovertip foreground color needed for
+recent macOS. Fixes Sonoma showing unreadable white on pale yellow.
+Patch by John Riggles.
+
gh-122482: Change About IDLE to direct users to discuss.python.org
instead of the now unused idle-dev email and mailing list.
diff --git a/Lib/idlelib/tooltip.py b/Lib/idlelib/tooltip.py
index 3983690..df5b1fe 100644
--- a/Lib/idlelib/tooltip.py
+++ b/Lib/idlelib/tooltip.py
@@ -144,7 +144,8 @@ class OnHoverTooltipBase(TooltipBase):
class Hovertip(OnHoverTooltipBase):
"A tooltip that pops up when a mouse hovers over an anchor widget."
- def __init__(self, anchor_widget, text, hover_delay=1000):
+ def __init__(self, anchor_widget, text, hover_delay=1000,
+ foreground="#000000", background="#ffffe0"):
"""Create a text tooltip with a mouse hover delay.
anchor_widget: the widget next to which the tooltip will be shown
@@ -156,10 +157,13 @@ class Hovertip(OnHoverTooltipBase):
"""
super().__init__(anchor_widget, hover_delay=hover_delay)
self.text = text
+ self.foreground = foreground
+ self.background = background
def showcontents(self):
label = Label(self.tipwindow, text=self.text, justify=LEFT,
- background="#ffffe0", relief=SOLID, borderwidth=1)
+ relief=SOLID, borderwidth=1,
+ foreground=self.foreground, background=self.background)
label.pack()