Skip to content

Commit

Permalink
added button to clear times
Browse files Browse the repository at this point in the history
Signed-off-by: Mina Mandic <[email protected]>
  • Loading branch information
minamandic committed Sep 30, 2024
1 parent 1e115a2 commit dd33f98
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
8 changes: 8 additions & 0 deletions racetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
"""
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit dd33f98

Please sign in to comment.