An easy and customisable ToolTip implementation for Tkinter
Project description
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.
Features
- normal tooltips
- show tooltip with
s
secondsdelay
- 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.
import tkinter as tk
import tkinter.ttk as ttk
from tktooltip import ToolTip
app = tk.Tk()
b = ttk.Button(app, text="Button").pack()
ToolTip(b, msg="Hover info")
app.mainloop()
Delayed tooltip
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.
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
.
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()
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
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()
Acknowledgements
tkinter-tooltip
is based on the original work performed by
Tucker Beck
licensed under an MIT License.
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file tkinter-tooltip-1.1.0.tar.gz
.
File metadata
- Download URL: tkinter-tooltip-1.1.0.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 165bb4dff16597eeec05a12d3d937daae64d3e36e4ecb1e1100e2891dd9604fa |
|
MD5 | ea90f2d02f805966556149b19dc28969 |
|
BLAKE2b-256 | 1488715b9af6edb1abb9af97abda7a8aed93d2cb061217e8b7abb527e80e445d |
Provenance
File details
Details for the file tkinter_tooltip-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: tkinter_tooltip-1.1.0-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca7ec340d140763a64d26bc8fe42e68d93ff87244e23e74b9d58d570e121905e |
|
MD5 | b72685ba5988d69eb0b85021252ea92f |
|
BLAKE2b-256 | 3582187937792590537a3004be724e8ee709a0e814bd4d23035e5ff3ad5d81ee |