Skip to content

Commit 683e33b

Browse files
committed
feat: Add argument to enable/disable animations
1 parent 697fa84 commit 683e33b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

tktooltip/tooltip.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def __init__(
4646
msg: str | list[str] | Callable[[], str | list[str]],
4747
delay: float = 0.0,
4848
follow: bool = True,
49+
animations: bool = True,
4950
refresh: float = 1.0,
5051
x_offset: int = +10,
5152
y_offset: int = +10,
@@ -67,6 +68,9 @@ def __init__(
6768
Delay in seconds before the ToolTip appears, by default 0.0
6869
follow : `bool`, optional
6970
ToolTip follows motion, otherwise hides, by default True
71+
animations : `bool`, optional
72+
ToolTip fades in when showing and fades out when hiding, by default True.
73+
This requires a compositing window manager on Linux to have any effect.
7074
refresh : `float`, optional
7175
Refresh rate in seconds for strings and functions when mouse is
7276
stationary and inside the widget, by default 1.0
@@ -93,6 +97,7 @@ def __init__(
9397
self._update_message()
9498
self.delay = delay
9599
self.follow = follow
100+
self.animations = animations
96101
self.refresh = refresh
97102
self.x_offset = x_offset
98103
self.y_offset = y_offset
@@ -155,7 +160,10 @@ def animation():
155160

156161
self.withdraw()
157162

158-
threading.Thread(target=animation, daemon=True).start()
163+
if self.animations:
164+
threading.Thread(target=animation, daemon=True).start()
165+
else:
166+
self.withdraw()
159167

160168
def _update_tooltip_coords(self, event: tk.Event) -> None:
161169
"""
@@ -213,7 +221,8 @@ def animation():
213221

214222
self.is_shown = True
215223

216-
threading.Thread(target=animation, daemon=True).start()
224+
if self.animations:
225+
threading.Thread(target=animation, daemon=True).start()
217226

218227
# Recursively call _show to update ToolTip with the newest value of msg
219228
# This is a race condition which only exits when upon a binding change

0 commit comments

Comments
 (0)