Skip to main content

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.

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").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. NOTE: the values do not update when the cursor is stationary.

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

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-0.0.4.tar.gz (513.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tkinter_tooltip-0.0.4-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tkinter-tooltip-0.0.4.tar.gz
  • Upload date:
  • Size: 513.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/1.6.0 pkginfo/1.7.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.6.9

File hashes

Hashes for tkinter-tooltip-0.0.4.tar.gz
Algorithm Hash digest
SHA256 e2e9192f001e10c4a5d6097bf95837798be8462b803a274288b40ea14df5f3ec
MD5 1f1c82769f92422050e0ef4d4c6f54cb
BLAKE2b-256 3efded59bb5740aed029cc2f16d262850c07c8e61dc80691171b7c23b575f3e2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tkinter_tooltip-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/1.6.0 pkginfo/1.7.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.6.9

File hashes

Hashes for tkinter_tooltip-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8b6724c2a1ed4c7c00147ce7a03f2f4640821f93dafefba7bd8dcd5566f66339
MD5 2a501437f61ade662e819d2c826c7f18
BLAKE2b-256 6729f017d502c32a4dcc3df51ee366fc14f5e89fbdabc3a27f7c7f9f94bc6538

See more details on using hashes here.

Supported by

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