Open VincentGreggPamor opened 2 years ago
Good Evening guys eto young code para sa update para mag update atong timer every seconds😊
def update():
global hours, minutes, seconds
seconds += 1
if seconds == 60:
minutes += 1
seconds = 0
if minutes == 60:
hours += 1
minutes = 0
# format time to include leading zeros
hours_string = f'{hours}' if hours > 9 else f'0{hours}'
minutes_string = f'{minutes}' if minutes > 9 else f'0{minutes}'
seconds_string = f'{seconds}' if seconds > 9 else f'0{seconds}'
# update timer every 1000ms to 1 sec
stopwatch_label.config(text=hours_string + ':' + minutes_string + ':' + seconds_string)
# after each seconds make an uosate on the timer
# use update_time variable to cancel or pause the time using after_cancel
global update_time
update_time = stopwatch_label.after(1000, update)
Python code for Stopwatch