A tooltip that pops up when a mouse hovers over an anchor widget.
| 143 | |
| 144 | |
| 145 | class Hovertip(OnHoverTooltipBase): |
| 146 | "A tooltip that pops up when a mouse hovers over an anchor widget." |
| 147 | def __init__(self, anchor_widget, text, hover_delay=1000, |
| 148 | foreground="#000000", background="#ffffe0"): |
| 149 | """Create a text tooltip with a mouse hover delay. |
| 150 | |
| 151 | anchor_widget: the widget next to which the tooltip will be shown |
| 152 | hover_delay: time to delay before showing the tooltip, in milliseconds |
| 153 | |
| 154 | Note that a widget will only be shown when showtip() is called, |
| 155 | e.g. after hovering over the anchor widget with the mouse for enough |
| 156 | time. |
| 157 | """ |
| 158 | super().__init__(anchor_widget, hover_delay=hover_delay) |
| 159 | self.text = text |
| 160 | self.foreground = foreground |
| 161 | self.background = background |
| 162 | |
| 163 | def showcontents(self): |
| 164 | label = Label(self.tipwindow, text=self.text, justify=LEFT, |
| 165 | relief=SOLID, borderwidth=1, |
| 166 | foreground=self.foreground, background=self.background) |
| 167 | label.pack() |
| 168 | |
| 169 | |
| 170 | def _tooltip(parent): # htest # |
no outgoing calls
searching dependent graphs…