Tooltip

class lib.gui.custom_widgets.Tooltip(widget, *, pad=(5, 3, 5, 3), text='widget info', text_variable=None, wait_time=400, wrap_length=250)

Bases: object

Create a tooltip for a given widget as the mouse goes on it.

Parameters:
  • widget (tkinter object) – The widget to apply the tool-tip to

  • pad (tuple, optional) – (left, top, right, bottom) padding for the tool-tip. Default: (5, 3, 5, 3)

  • text (str, optional) – The text to be displayed in the tool-tip. Default: ‘widget info’

  • text_variable (tkinter.strVar, optional) – The text variable to use for dynamic help text. Appended after the contents of text if provided. Default: None

  • wait_time (int, optional) – The time in milliseconds to wait before showing the tool-tip. Default: 400

  • wrap_length (int, optional) – The text length for each line before wrapping. Default: 250

Example

>>> button = ttk.Button(parent, text="Exit")
>>> Tooltip(button, text="Click to exit")
>>> button.pack()

Notes

Adapted from StackOverflow: http://stackoverflow.com/questions/3221956 and http://www.daniweb.com/programming/software-development/code/484591/a-tooltip-class-for-tkinter