From 6547d12093cf88bcd40c714117ec8b15345f8379 Mon Sep 17 00:00:00 2001 From: Tristan Smith Date: Sat, 17 Feb 2024 22:36:39 -0500 Subject: [PATCH] I don't remember what I did. --- tap.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tap.py b/tap.py index 0a4bb43..cc3d0af 100644 --- a/tap.py +++ b/tap.py @@ -16,8 +16,11 @@ def calculate_bpm(): #calculate difference between first and last click time_diff = click_times[-1] - click_times[-2] #calculate bpm based on time difference - bpm = int(60 / time_diff) - bpm_label.config(text=f"BPM: + {bpm}") + if time_diff > 0: + bpm = int(60 / time_diff) + bpm_label.config(text=f"BPM: {bpm:.2f}") + else: + bpm_label.config(text="BPM: Max") else: bpm_label.config(text="BPM: N/A") @@ -46,14 +49,14 @@ root.geometry("300x200") # Create and place bpm label -bpm_label = tk.Label(root, text="BPM: N/A", font=("Helvetica", 24)) +bpm_label = tk.Label(root, text="BPM: N/A", font=("Verdana", 24)) bpm_label.pack(pady=20) # Create and place start/stop button -start_stop_button = tk.Button(root, text="Start", font=("Helvetica", 18), command=start_stops) +start_stop_button = tk.Button(root, text="Start", font=("Verdana", 18), command=start_stops) start_stop_button.pack(pady=20) -root.bind("", handle_click) -root.bind("", handle_click) +root.bind("