MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / add_tooltip

Function add_tooltip

lib/matplotlib/backends/_backend_tk.py:970–1001  ·  view source on GitHub ↗
(widget, text)

Source from the content-addressed store, hash-verified

968
969
970def add_tooltip(widget, text):
971 tipwindow = None
972
973 def showtip(event):
974 """Display text in tooltip window."""
975 nonlocal tipwindow
976 if tipwindow or not text:
977 return
978 x, y, _, _ = widget.bbox("insert")
979 x = x + widget.winfo_rootx() + widget.winfo_width()
980 y = y + widget.winfo_rooty()
981 tipwindow = tk.Toplevel(widget)
982 tipwindow.overrideredirect(1)
983 tipwindow.geometry(f"+{x}+{y}")
984 try: # For Mac OS
985 tipwindow.tk.call("::tk::unsupported::MacWindowStyle",
986 "style", tipwindow._w,
987 "help", "noActivates")
988 except tk.TclError:
989 pass
990 label = tk.Label(tipwindow, text=text, justify=tk.LEFT,
991 relief=tk.SOLID, borderwidth=1)
992 label.pack(ipadx=1)
993
994 def hidetip(event):
995 nonlocal tipwindow
996 if tipwindow:
997 tipwindow.destroy()
998 tipwindow = None
999
1000 widget.bind("<Enter>", showtip)
1001 widget.bind("<Leave>", hidetip)
1002
1003
1004@backend_tools._register_tool_class(FigureCanvasTk)

Callers 2

__init__Method · 0.85
add_toolitemMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…