Updates the widget to show the ETA or total time when finished.

def _calculate_eta(self, progress, data, value, elapsed):
        '''Updates the widget to show the ETA or total time when finished.'''
        if elapsed:
            # The max() prevents zero division errors
            per_item = elapsed.total_seconds() / max(value, 1e-6)
            remaining = progress.max_value - data['value']
            eta_seconds = remaining * per_item
        else:
            eta_seconds = 0

        return eta_seconds