Timer Stops When Switching Browser Tabs

Thanks @p.colbert, that is both helpful and hilariously obvious in retrospect. If you want to know the time, better look at the clock! :joy:

This works:

from ._anvil_designer import Form1Template
from anvil import *
import time

class Form1(Form1Template):
    def __init__(self, **properties):
        self.init_components(**properties)
        self.start_time = None
        self.timer_1.interval = 0.0  # Timer initially inactive

    def start_timer(self, **event_args):
        print("start_timer pressed")
        self.start_time = time.time()        
        self.timer_1.interval = 0.1  # Start ticking every 0.1 seconds

    def timer_1_tick(self, **event_args):
        elapsed_seconds = time.time() - self.start_time
        self.label_1.text = f"Elapsed time: {elapsed_seconds:.1f} s"