https://github.com/gnikit/tkinter-tooltip
A ToolTip widget for tkinter
https://github.com/gnikit/tkinter-tooltip
dark-theme gui python tkinter tooltip
Last synced: about 1 year ago
JSON representation
A ToolTip widget for tkinter
- Host: GitHub
- URL: https://github.com/gnikit/tkinter-tooltip
- Owner: gnikit
- License: mit
- Created: 2021-10-26T19:10:12.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-03-03T17:09:42.000Z (over 1 year ago)
- Last Synced: 2025-03-29T17:12:53.899Z (about 1 year ago)
- Topics: dark-theme, gui, python, tkinter, tooltip
- Language: Python
- Homepage: https://gnikit.github.io/tkinter-tooltip
- Size: 4 MB
- Stars: 43
- Watchers: 1
- Forks: 6
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
[](https://pepy.tech/project/tkinter-tooltip)
[](https://pypi.org/project/tkinter-tooltip/)
[](https://github.com/gnikit/tkinter-tooltip/actions/workflows/main.yml)
[](https://github.com/gnikit/tkinter-tooltip/actions/workflows/docs.yml)
[](https://codecov.io/gh/gnikit/tkinter-tooltip)
[](https://github.com/gnikit/tkinter-tooltip/blob/master/LICENSE)
[](https://github.com/psf/black)
[](https://github.com/sponsors/gnikit)
[](https://paypal.me/inikit)
# 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` seconds `delay`
- tooltip tracks mouse cursor
- tooltip displays strings and string returning functions
- fully customisable, tooltip inherits underlying theme style
## Install
```shell
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.

```python
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

```python
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.

```python
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`.


```python
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

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.
```python
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](CONTRIBUTING.md) file.
## Acknowledgements
`tkinter-tooltip` is based on the original work performed by
[Tucker Beck](http://code.activestate.com/recipes/576688-tooltip-for-tkinter/)
licensed under an MIT License.
## License
[MIT](LICENSE) License