Skip to main content

Downloads PyPI Latest Release Tests Documentation codecov PyPI - License Code style: black

GitHub Sponsor PyaPal

tkinter-tooltip

What this is

This is a simple yet fully customisable tooltip/pop-up implementation for tkinter widgets. It is capable of fully integrating with custom tkinter themes both light and dark ones.

alt

Features

  • normal tooltips
  • show tooltip with s seconds delay
  • tooltip tracks mouse cursor
  • tooltip displays strings and string returning functions
  • fully customisable, tooltip inherits underlying theme style

Install

pip install tkinter-tooltip

Examples

Normal tooltips

By default the tooltip activates when entering and/or moving in the widget are and deactivates when leaving and/or pressing any button.

alt

import tkinter as tk
import tkinter.ttk as ttk
from tktooltip import ToolTip

app = tk.Tk()
b = ttk.Button(app, text="Button")
b.pack()
ToolTip(b, msg="Hover info")
app.mainloop()

Delayed tooltip

alt

import tkinter as tk
import tkinter.ttk as ttk
from tktooltip import ToolTip

app = tk.Tk()
b = ttk.Button(app, text="Button")
b.pack()
ToolTip(b, msg="Hover info", delay=2.0)   # True by default
app.mainloop()

Tracking tooltip

Have the tooltip follow the mousse cursor around when moving.

alt

import tkinter as tk
import tkinter.ttk as ttk
from tktooltip import ToolTip

app = tk.Tk()
b = ttk.Button(app, text="Button")
b.pack()
ToolTip(b, msg="Hover info", follow=True)   # True by default
app.mainloop()

Function as tooltip

Here the tooltip returns the value of time.asctime() which updates with every movement. You can control the refresh rate of the ToolTip through the refresh argument by default it is set to 1s.

alt alt

import time
import tkinter as tk
import tkinter.ttk as ttk
from tktooltip import ToolTip

app = tk.Tk()
b = ttk.Button(app, text="Button")
b.pack()
# NOTE: pass the function itself not the return value
ToolTip(b, msg=time.asctime, delay=0)
app.mainloop()

Themed tooltip

tkinter-tooltip is fully aware of the underlying theme (in this case a dark theme), and can even be furher customised by passing tk styling arguments to the tooltip

alt

Style tooltip and underlying the button. If a full theme has been used then the ToolTip will inherit the settings of the theme by default.

import tkinter as tk
import tkinter.ttk as ttk
from tktooltip import ToolTip

app = tk.Tk()
s = ttk.Style()
s.configure("custom.TButton", foreground="#ffffff", background="#1c1c1c")
b = ttk.Button(app, text="Button", style="custom.TButton")
b.pack()
ToolTip(b, msg="Hover info", delay=0,
        parent_kwargs={"bg": "black", "padx": 5, "pady": 5},
        fg="#ffffff", bg="#1c1c1c", padx=10, pady=10)
app.mainloop()

Notes

  • Certain options do not match great with each other, a good example is follow and delay using small x/y offsets. This can cause the tooltip to appear inside the widget. Hovering over the tooltip will cause it to disappear and reappear, in a new position, potentially again inside the widget.

Contributing

You can find the instructions on how to contribute in this project in the CONTRIBUTING.md file.

Acknowledgements

tkinter-tooltip is based on the original work performed by Tucker Beck licensed under an MIT License.

License

MIT License

Metadata

Release files for tkinter-tooltip 3.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tkinter-tooltip 3.1.2
File Size Uploaded
tkinter_tooltip-3.1.2.tar.gz 859.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tkinter-tooltip 3.1.2
File Interpreter ABI Platform
tkinter_tooltip-3.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 867.6 kB

Release files / tkinter_tooltip-3.1.2.tar.gz

Download URL tkinter_tooltip-3.1.2.tar.gz
Size 859.8 kB
Tags Source
SHA-256 checksum
How to use checksums
dac8a6720c851936dfea2d96f90920a4dac31b46b78379c5e0ef0b6ed8af2964
BLAKE2b-256 checksum
How to use checksums
a9f1e864d09013055e4c372995214efbd217415d8c8e91af2dbc91aaabe81f39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.20

Release files / tkinter_tooltip-3.1.2-py3-none-any.whl

Download URL tkinter_tooltip-3.1.2-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5bad74f2d476d9e2418598b2438f06e4b658dd6a89ee39a0bbfebb4fb7fdeb7f
BLAKE2b-256 checksum
How to use checksums
faa0b1d00dce752c2a3dad72515196da8b40816eac8385b2f901352cee9086c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.20

Release history Release notifications | RSS feed

This release

3.1.2 This release

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.0

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page