Skip to main content

Python Tkinter Tooltip

This is a simple and basic python class aimed to show a tooltip when hovering a tkinter widget.

How to use it

To use the tooltip class in your project just follow these simple steps:

  1. install it with pip install python-tkinter-tooltip
  2. import it in your python file with from tkinter_tooltip import Tooltip
  3. create an instance of the tooltip class
  4. set the tooltip

Insert this line of code to create a tooltip object

my_tooltip = Tooltip(root)

When creating a new tooltip object only one parameter is required, the main window of your application (the root Tk() window). The tooltip is drawn inside that window and its position is calculated relative to it, so don't pass a Toplevel or a frame. There are few parameters that can be optionally configured.

delay=1500,             # milliseconds to wait before showing the tooltip
bg="yellow",            # tooltip background color
fg="#666666",           # tooltip foreground color
pad=(3, 3),             # padding value (x, y)
offset=(20, -10),       # (x, y) offset in pixels from the mouse pointer
size=7                  # font size

Set the tooltip calling this method using the following syntax:

my_tooltip.set(target_widget, tooltip_content, follow)

Three parameters can be set:

  1. target_widget.

    Which object will activate the tooltip. It can be a label, a button or any other tkinter widget

  2. tooltip_content.

    The actual text to be displayed on the tooltip.

    If no tooltip_content is provided the tooltip itself will be shown. This way you can setup complex tooltips by adding content to my_tooltip using standard tkinter methods.

  3. follow.

    Boolean value True or False. If set to true the tooltip will follow your mouse pointer. Default value is False

Demo examples

Inside the file called demo.py you will find examples of simple and advanced usage. The demos are only in the repository, not in the pip package, and they need Pillow (pip install pillow).

Notes

  • The tooltip automatically changes its position if there's not enough space
  • Clicking the target widget with any mouse button hides the tooltip
  • The tooltip is also hidden if the target widget is destroyed
  • Your own bindings on the target widget keep working: the tooltip adds its bindings without replacing yours. If you bind the same event later with bind(), pass add="+" or you will replace the tooltip's binding
  • Calling set() again on the same widget updates its text and follow setting

Project page

www.egw.it/projects/tkinter-tooltip

Metadata

Release files for python-tkinter-tooltip 2.7.22

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

Source distribution (sdist)

Source distribution for python-tkinter-tooltip 2.7.22
File Size Uploaded Provenance Actions
python_tkinter_tooltip-2.7.22.tar.gz 5.1 kB Without provenance Details for python_tkinter_tooltip-2.7.22.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for python-tkinter-tooltip 2.7.22
File Interpreter ABI Platform Actions
python_tkinter_tooltip-2.7.22-py3-none-any.whl Python 3 none any Details for python_tkinter_tooltip-2.7.22-py3-none-any.whl

Total release size: 11.4 kB

Release files / python_tkinter_tooltip-2.7.22.tar.gz

Download URL python_tkinter_tooltip-2.7.22.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
cd49104c2aaaf6693c5c65a9887fcb2b360e90ada7804c416b783de86d471d1c
BLAKE2b-256 checksum
How to use checksums
6476eb5959ac665ac4c68afa6f5c361af5cf6d221c7da28f6ba24a6a0122623d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.15

Release files / python_tkinter_tooltip-2.7.22-py3-none-any.whl

Download URL python_tkinter_tooltip-2.7.22-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9e0ac6e1ae9ea29710b2308d151b62dccaa93cec2ce4d59b16952e8f916786ee
BLAKE2b-256 checksum
How to use checksums
ae7e6b6945b470770558531e0b131b83387f62716e9572fa58529321bc43ae63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.15

Security for python-tkinter-tooltip 2.7.22

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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