MCPcopy Index your code
hub / github.com/geekcomputers/Python / calculate

Function calculate

Timetable_Operations.py:35–49  ·  view source on GitHub ↗

Tkinter callback to calculate and display clock difference.

()

Source from the content-addressed store, hash-verified

33
34
35def 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
52root = tk.Tk()

Callers

nothing calls this directly

Calls 2

clock_diffFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected