Tkinter callback to calculate and display clock difference.
()
| 33 | |
| 34 | |
| 35 | def calculate() -> None: |
| 36 | """Tkinter callback to calculate and display clock difference.""" |
| 37 | t1 = entry_t1.get().strip() |
| 38 | t2 = entry_t2.get().strip() |
| 39 | try: |
| 40 | for t in [t1, t2]: |
| 41 | if len(t) != 8 or t[2] != ":" or t[5] != ":": |
| 42 | raise ValueError("Format must be HH:MM:SS") |
| 43 | h, m, s = int(t[0:2]), int(t[3:5]), int(t[6:8]) |
| 44 | if not (0 <= h < 24 and 0 <= m < 60 and 0 <= s < 60): |
| 45 | raise ValueError("Time out of range") |
| 46 | result = clock_diff(t1, t2) |
| 47 | label_result.config(text=f"Difference: {result}") |
| 48 | except Exception as e: |
| 49 | messagebox.showerror("Error", f"Invalid input!\n{e}") |
| 50 | |
| 51 | |
| 52 | root = tk.Tk() |
nothing calls this directly
no test coverage detected