From 3aa2be909c4e74d1f7fd1baa6dfad76f9792b92c Mon Sep 17 00:00:00 2001 From: Jannes Magnusson Date: Fri, 17 Oct 2025 20:41:13 +0200 Subject: [PATCH] add pulse to timer --- frontend/views/timer.py | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/frontend/views/timer.py b/frontend/views/timer.py index 8c5579a..d333fca 100644 --- a/frontend/views/timer.py +++ b/frontend/views/timer.py @@ -7,13 +7,15 @@ import math from .base import View class TimerView(View): - def __init__(self, parent, size, center, width=5, **kwargs): + def __init__(self, parent, size, center, width=3, **kwargs): self.start_time = None self.elapsed_time = 0 self.is_running = False self.goal_minutes = 0 # 0 means no goal set - self.radius = min(center)-width + self.radius = min(center) - 7 self.width = width + self.goal_achived = 0 + self.goal_pulse_freq = 0.1 super().__init__(parent, size, center, **kwargs) def init_ui(self, parent): @@ -83,15 +85,22 @@ class TimerView(View): if progress > 0: inverted = int(progress) % 2 == 1 - progress = progress % 1.0 # Loop every full circle - start = self.center[0] - self.radius, self.center[1] - self.radius - end = self.center[0] + self.radius, self.center[1] + self.radius - - if inverted: - draw.arc((start, end), 360 * progress - 90, 270, fill='black', width=self.width) + # pulse width if goal achieved + if int(progress) > 0 and self.is_running: + self.goal_achived = (self.goal_achived + self.goal_pulse_freq) % 3 else: - draw.arc((start, end), 270, 360 * progress - 90, fill='black', width=self.width) + self.goal_achived = 0 + pulse = int(self.goal_achived) + + start = self.center[0] - self.radius - pulse, self.center[1] - self.radius - pulse + end = self.center[0] + self.radius + pulse, self.center[1] + self.radius + pulse + + progress = progress % 1.0 # Loop every full circle + if inverted: + draw.arc((start, end), 360 * progress - 90, 270, fill='black', width=self.width + pulse) + else: + draw.arc((start, end), 270, 360 * progress - 90, fill='black', width=self.width + pulse) except (ValueError, tk.TclError): # Invalid goal value, just show time without progress