8000 Add IDLE Hovertip foreground color needed for recent macOS · Issue #120083 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
Add IDLE Hovertip foreground color needed for recent macOS #120083
Closed
@JRiggles

Description

@JRiggles

Bug report

Bug description:

Minimal Reproducible Example

import tkinter as tk
from idlelib.tooltip import Hovertip

root = tk.Tk()
root.geometry('200x100')
label = tk.Label(root, text='Hover Me!')
label.pack()
tip = Hovertip(label, text='Pro Tip')
root.mainloop()

CleanShot 2024-06-04 at 20 04 12@2x

Proposed Fix

Specifying a foreground color, e.g. foreground="black", at the Label declaration in Hovertip.showcontents() fixes the issue

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):
        """Create a text tooltip with a mouse hover delay.

        anchor_widget: the widget next to which the tooltip will be shown
        hover_delay: time to delay before showing the tooltip, in milliseconds

        Note that a widget will only be shown when showtip() is called,
        e.g. after hovering over the anchor widget with the mouse for enough
        time.
        """
        super().__init__(anchor_widget, hover_delay=hover_delay)
        self.text = text

    def showcontents(self):
        label = Label(self.tipwindow, text=self.text, justify=LEFT,
                      foreground="black", background="#ffffe0", relief=SOLID, borderwidth=1)
        label.pack()

CleanShot 2024-06-04 at 20 08 07@2x

CPython versions tested on:

3.12

Operating systems tested on:

macOS

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic-IDLEtype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0