Skip to main content

An easy and customisable ToolTip implementation for Tkinter

Project description

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()

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tkinter-tooltip-2.2.0.tar.gz (858.5 kB view details)

Uploaded Source

Built Distribution

tkinter_tooltip-2.2.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file tkinter-tooltip-2.2.0.tar.gz.

File metadata

  • Download URL: tkinter-tooltip-2.2.0.tar.gz
  • Upload date:
  • Size: 858.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for tkinter-tooltip-2.2.0.tar.gz
Algorithm Hash digest
SHA256 4f11facba5ac00a068abac88874b435f40e0049514aea979caee757877bb8e82
MD5 342c10b025d057417b090652f915c39b
BLAKE2b-256 90362a219efebab4ee42a0f4ecb899d371a8274bf74c33575959f94d60afeedd

See more details on using hashes here.

Provenance

File details

Details for the file tkinter_tooltip-2.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for tkinter_tooltip-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5056fabc6e19221db01f64408ee27501a9a83f9c88a619bb48eae39c0d9bfd46
MD5 2d0878828d7562abad5f025681869adb
BLAKE2b-256 bba213f7d3fe7c36d92796af77c1d2da988ad983aef22639f98bc7a827d73ad3

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page