Display text in tooltip window.
(event)
| 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 |
nothing calls this directly
no test coverage detected
searching dependent graphs…