Using the Anvil-extras determinate progress bar

I am trying to implement the Anvil-extras determinate progress bar without success. I would like it to show progress as images are loaded from the server to a browser cache. The progress bar appears in the UI and disappears when the images are completely loaded, which is correct. I have used the timer component to update the progress bar at short intervals, except it doesn’t update. Does anyone know of sample code for a working progress bar?

I have also tried asynchronous loading but that didn’t work either, and synchronous loading seems simpler. This is my current code with debug print statements that don’t help much. I might be missing something very simple!

    def timer_tick(self, **event_args):
        # Load a batch of thumbnails
        returned_batch_size = self.call_server_for_thumbnails(self.start_index)

        print(f"Before incrementing start_index: {self.start_index}")
        print(f"Batch size: {self.batch_size}")
      
        # Increment the start index
        self.start_index += self.batch_size
        print(f"After incrementing start_index: {self.start_index}")

        # Calculate the progress fraction and update the progress bar
        progress_fraction = self.start_index / self.total_species
        self.progress = progress_fraction

        # Update the progress bar
        self.update_progress_bar()
    
        # If finished loading, stop the timer
        if self.start_index >= self.total_species or returned_batch_size == 0:
            print("Stopping condition met. start_index:", self.start_index, "total_species:", self.total_species)
            self.timer.interval = 0
            self.progress_bar.visible = False
            self.progressbar_label.visible = False
            print("Timer stopped.")
        else:
            print("Stopping condition not met. Continuing...")

  def update_progress_bar(self):
       print(f"Updating progress bar value to: {self.progress}")  # Debugging print statement
       self.progress_bar.value = self.progress
       self.progressbar_label.visible = self.progress_bar.visible
       self.refresh_data_bindings()

Any pointers much appreciated. Thanks in advance.
S

Thanks to anyone who has looked at my question. I could not figure out a solution with the Anvil-extras progress bar, but I coded my own using a label on top of a flow panel. It isn’t as aesthetically pleasing as the Anvil-extras progress bar, as I couldn’t set the height to make a narrow bar… but it works well!
S