From dd33f980bfe58289df3965486eeed991086adf2d Mon Sep 17 00:00:00 2001 From: Mina Mandic Date: Sun, 29 Sep 2024 22:59:34 -0400 Subject: [PATCH] added button to clear times Signed-off-by: Mina Mandic --- main_window.py | 7 +++++++ racetimes.py | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/main_window.py b/main_window.py index a427552d..ffe8acfe 100644 --- a/main_window.py +++ b/main_window.py @@ -427,6 +427,11 @@ def __init__(self, parent: Widget, vm: Model) -> None: latestres.grid(column=0, row=0, rowspan=2, sticky="news") ToolTip(latestres, "Raw data from the latest race result") + def clear_time(self): + race_times = self._vm.latest_result.get() + race_times.clear_time() + self._vm.latest_result.set(race_times) + def _cc_selector(self, parent: Widget) -> Widget: frame = ttk.LabelFrame(parent, text="Available Chromecasts") frame.columnconfigure(0, weight=1) @@ -442,4 +447,6 @@ def _preview(self, parent: Widget) -> Widget: frame.rowconfigure(0, weight=1) widgets.Preview(frame, self._vm.scoreboard).grid(column=0, row=0) ToolTip(frame, "Current contents of the scoreboard") + button = ttk.Button(parent, text="Clear", command=self.clear_time) + return frame diff --git a/racetimes.py b/racetimes.py index 29813f59..87b4a705 100644 --- a/racetimes.py +++ b/racetimes.py @@ -160,6 +160,10 @@ def final_time(self, lane: int) -> Time: if abs(time - final) > self.threshold: valid = False return Time(final, valid) + + def clear_time(self): + """Clear all the times from the scoreboard""" + pass def place(self, lane: int) -> Optional[int]: """ @@ -263,6 +267,10 @@ def __init__( def raw_times(self, lane: int) -> List[Optional[RawTime]]: return self._lanes[lane - 1] + + def clear_time(self): + for time in range(10): + self._lanes = [None, None, None] @property def event(self) -> int: