Metadata-Version: 2.4
Name: python-tkinter-tooltip
Version: 2.7.22
Summary: A simple tooltip class for tkinter widgets
Author-email: Enrico Galli <enrico@egw.it>
License: The MIT License (MIT)
        
        Copyright (c) <2020> <Enrico Galli>
        
        Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Project-URL: Homepage, https://www.egw.it/projects/tkinter-tooltip
Project-URL: Repository, https://gitlab.com/enricogalli/python-tkinter-tooltip
Keywords: tkinter,tooltip,gui
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: User Interfaces
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# 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](https://www.egw.it/projects/tkinter-tooltip)
