{"id":20645502,"url":"https://github.com/pedrohenriques/tkinter_tooltips","last_synced_at":"2025-07-12T23:37:52.125Z","repository":{"id":91937482,"uuid":"58287380","full_name":"PedroHenriques/Tkinter_ToolTips","owner":"PedroHenriques","description":"A standalone python class that will handle showing and hiding tooltips for single or multiple tkinter widgets.","archived":false,"fork":false,"pushed_at":"2016-05-08T22:29:04.000Z","size":9,"stargazers_count":11,"open_issues_count":1,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-16T02:12:02.215Z","etag":null,"topics":["python-tooltips","tkinter-tooltips","tooltip"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PedroHenriques.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-05-07T22:44:01.000Z","updated_at":"2024-04-04T11:35:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"d6d5ab67-b175-416c-9eac-fddab344e700","html_url":"https://github.com/PedroHenriques/Tkinter_ToolTips","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PedroHenriques%2FTkinter_ToolTips","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PedroHenriques%2FTkinter_ToolTips/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PedroHenriques%2FTkinter_ToolTips/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PedroHenriques%2FTkinter_ToolTips/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PedroHenriques","download_url":"https://codeload.github.com/PedroHenriques/Tkinter_ToolTips/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249183106,"owners_count":21226142,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python-tooltips","tkinter-tooltips","tooltip"],"created_at":"2024-11-16T16:20:09.161Z","updated_at":"2025-04-16T02:12:23.284Z","avatar_url":"https://github.com/PedroHenriques.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tkinter ToolTips in Python\n\nA standalone python class that will handle showing and hiding tooltips for single or multiple tkinter widgets.\n\nThe code will show the tooltip when a widget is hovered over and will dynamically adjust the tooltip's position and size to make sure it fits the window.\n\n## Instructions\n\n### Setup\n\nIn order to use this class you need to:\n\n1. Place a copy of **ToolTips.py** in your program's folder.\n2. On the file(s) you want to use the tooltips import this class with `import ToolTips`.\n3. Instantiate the class providing a List of widgets, a List of tooltip text strings and an optional Tkinter Font object, in the form `tooltip_obj = ToolTips.ToolTips(widgets, tooltip_text, font_obj)`\n\nThere are several class variables that can be used to customize the tooltip's styles and position.\n\n### Parameters\n\nThe class constructor receives **3 parameters**, 2 mandatory and 1 optional.\n\n1. A list of widget references. These widgets are the ones you want tooltips on.\n2. A list of strings with the tooltip text for each of the widgets on the list\n3. [OPTIONAL] A tkinter font object to be used for the tooltip text.\n\nIf a font isn't provided, the tooltips will use the default font family and font size set on the respective class variables.  \nBy default the font family is \"Helvetica\" and the font size is 12.\n\nRegarding the List of widgets and the List of strings, they should have **matching indexes**, i.e., the first string on the list should be the tooltip of the first widget on the other list, and so on.\n\n### Demo\n\nThe file `demo.py` contains a simple tkinter GUI integrating the tooltip code, which can be used as a reference on how to use this class, if needed.\n\n## Technical Information\n\n### Binds and Events\n\nThe constructor will set 3 binds for each of the supplied widgets.\n\n- **\u0026lt;Enter\u0026gt;** --\u003e When the mouse enters the widget area the tooltip will be displayed.\n- **\u0026lt;Leave\u0026gt;** --\u003e When the mouse leaves the widget area the tooltip will be removed.\n- **\u0026lt;Button-1\u0026gt;** --\u003e When the widget is clicked with the LMB the tooltip will be removed.\n\nYou can set your own binds for showing and removing a widget's tooltips, by calling the `showToolTips()` method to show the tooltip and calling the `hideToolTips()` method to remove the tooltip.\n\n**NOTE:**  \nIf your code is adding binds for the same widgets and events, make sure to add them to the bind list, rather than replacing the tooltip's binds.  \nThis can be done using the following syntax `widget.bind(\"event\", callback, add=\"+\")`\n\n### Placement of the ToolTip\n\nBy default the tooltip will be placed below the respective widget and aligned with it's west border.  \nThe code will also add line breaks to the tooltip string in order to avoid overflowing the window.\n\nHowever, if there isn't enough space on the window for the default placement, the code will try moving the tooltip around the widget to check if it fits on the window.  \nIf no position can be found, then the tooltip will try using the entire window width, i.e., it will no longer be aligned with the widget's west border.  \nIf it still doesn't fit the window, then the code will start reducing the font size of the tooltip text until it either fits or the font size reaches 1.\n\n### Other Information\n\nThe code will try using as much of the window's width to show the tooltip, but there will be some unused space as a safeguard.  \nThis is needed due to the dynamics of fonts, specifically the width of it's characters and how many characters can be inserted in each of the tooltip's lines.  \nIn order to avoid using a more complex algorithm, that would slow down your program, a simpler solution was used with the downside of requiring a safety margin.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpedrohenriques%2Ftkinter_tooltips","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpedrohenriques%2Ftkinter_tooltips","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpedrohenriques%2Ftkinter_tooltips/lists"}