diff --git a/animated_icon.py b/animated_icon.py index 4cfe8fd..070ac36 100644 --- a/animated_icon.py +++ b/animated_icon.py @@ -55,6 +55,7 @@ class AnimatedIcon(tk.Canvas): self.highlight_color = highlight_color self.use_pillow = use_pillow and PIL_AVAILABLE self.running = False + self.is_disabled = False self.pause_count = 0 self.angle = 0 self.pulse_animation = False @@ -334,10 +335,22 @@ class AnimatedIcon(tk.Canvas): def _draw_stopped_frame(self) -> None: """Draws the icon in its stopped (static) state.""" self.delete("all") - if self.use_pillow: - self._draw_pillow_stopped_frame() - else: - self._draw_canvas_stopped_frame() + + original_highlight_color = self.highlight_color + original_highlight_color_rgb = self.highlight_color_rgb + if self.is_disabled: + self.highlight_color = "#8f99aa" + self.highlight_color_rgb = _hex_to_rgb(self.highlight_color) + + try: + if self.use_pillow: + self._draw_pillow_stopped_frame() + else: + self._draw_canvas_stopped_frame() + finally: + if self.is_disabled: + self.highlight_color = original_highlight_color + self.highlight_color_rgb = original_highlight_color_rgb def _draw_canvas_stopped_frame(self) -> None: """Draws the stopped state using canvas methods.""" @@ -480,6 +493,7 @@ class AnimatedIcon(tk.Canvas): if not self.winfo_exists(): return self.running = True + self.is_disabled = False self.pulse_animation = pulse if self.pause_count == 0: self._animate() @@ -490,19 +504,8 @@ class AnimatedIcon(tk.Canvas): return self.running = False self.pulse_animation = False - - if status == "DISABLE": - original_highlight_color = self.highlight_color - original_highlight_color_rgb = self.highlight_color_rgb - self.highlight_color = "#8f99aa" - self.highlight_color_rgb = _hex_to_rgb(self.highlight_color) - try: - self._draw_stopped_frame() - finally: - self.highlight_color = original_highlight_color - self.highlight_color_rgb = original_highlight_color_rgb - else: - self._draw_stopped_frame() + self.is_disabled = status == "DISABLE" + self._draw_stopped_frame() def hide(self) -> None: """Stops the animation and clears the canvas.""" @@ -528,4 +531,4 @@ class AnimatedIcon(tk.Canvas): if not self.winfo_exists(): return if not self.running: - self._draw_stopped_frame() \ No newline at end of file + self._draw_stopped_frame()