fix(animated_icon): Behebt Fehler bei der Wiederherstellung des DISABLE-Status
This commit is contained in:
@@ -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()
|
||||
self._draw_stopped_frame()
|
||||
|
Reference in New Issue
Block a user