Skip to content

Added CTkTooltip#1093

Open
supercam19 wants to merge 8 commits intoTomSchimansky:masterfrom
supercam19:tooltips
Open

Added CTkTooltip#1093
supercam19 wants to merge 8 commits intoTomSchimansky:masterfrom
supercam19:tooltips

Conversation

@supercam19
Copy link

@supercam19 supercam19 commented Jan 22, 2023

I have added tooltips which appear when your mouse hovers over a widget. These can be very useful for describing the purposes of widgets such as buttons, without using the widget's text to describe it. This is possible using Toplevels and transparent colors to give the tooltip rounded edges.

image

Here is a more practical example, where tooltips are used to indicate the usage of a button represented only with an icon:
image
Allowing for a clean and modern user interface.

Please consider adding this as I think many people would find it useful

@supercam19 supercam19 changed the title Add CTkTooltip Added CTkTooltip Jan 22, 2023
@TomSchimansky
Copy link
Owner

The implementation looks good, but the problem is that it does not work on all platforms, for example on macOS in fullscreen mode, it would open a new tab, because you cannot open a secondary window in fullscreen mode above the existing one there.

@UserJoo9
Copy link

awesome, am very interest !!!

Fixed errors using MacOS trying to create a tooltip
@supercam19
Copy link
Author

supercam19 commented Jan 27, 2023

I've tested tooltips in MacOS fullscreen and they seem to work as expected.

Converting PR to a draft to fix some differences across platforms issues caused by slow machines

@supercam19 supercam19 marked this pull request as draft January 27, 2023 22:32
@supercam19 supercam19 marked this pull request as ready for review January 29, 2023 07:09
@Wolf-SO
Copy link

Wolf-SO commented Feb 1, 2023

I see accessibility issues with the color scheme shown. In general, tooltips seem to be designed to stand out visually. So what about inverting colors?

But maybe the colors shown in the first image of the initial comment are not up-to-date? Would you please add a new screenshot in that case? Thanks.

@supercam19
Copy link
Author

@Wolf-SO you're right, I hadn't updated the screenshot yet. The image has now been changed to show the higher contrast to the default colors of the theme.

@IshanJ25
Copy link

nice

can it track mouse movement to update location in real-time?

- Fix .configure() not working
- Fix tooltips sometimes not disappearing
- Add is_visible() method to return visibility status
@supercam19
Copy link
Author

@IshanJ25 It's not built in to the tooltip, but it can still be done. Ex:

import customtkinter
import threading
import time

app = customtkinter.CTk()

def track_mouse():
    tooltip_1.configure(delay=0)
    while app.winfo_exists():
        if tooltip_1.is_visible():
            tooltip_1.geometry(f'{app.winfo_pointerx()+1}+{app.winfo_pointery()+1}')
            time.sleep(0.02)

frame_1 = customtkinter.CTkFrame(master=app)
frame_1.pack(pady=20, padx=60, fill="both", expand=True)

button_1 = customtkinter.CTkButton(master=frame_1)
button_1.pack(pady=10, padx=10)
tooltip_1 = customtkinter.CTkTooltip(master=button_1)
tooltip_follow_thread = threading.Thread(target=track_mouse)
tooltip_follow_thread.start()

app.mainloop()

@FedericoSpada
Copy link
Collaborator

Hi,
I've developed the same widget myself for a project.
I've tried to replicate the look of the Microsoft Office ToolTips, with a short title and a description:
Screenshot_2026 01 07_08 51 15
It can also update its content dynamically.

The difference is that I've used a CTkFrame properly placed instead of a CTkTopLevel. I plan to make it available in a next release.
For now, I leave this PR open so that it is more searchable if someone in the meantime wants to use this one.

@ElectricCandlelight
Copy link

Akascape has a really nice tooltip, worth a look. CTkToolTip

@FedericoSpada
Copy link
Collaborator

Coincidentally, someone else just pointed out the same widget in #2254, and it turned out that it is mixing Tk and CTk widgets, resulting in an Exception.
I'll have a look if it has additional useful features that are missing from both this version and mine, and I'll try to integrate them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants