Skip to content

ProgressBar: decrease CPU consumption by adjusting Bar.auto_refresh when styles.display is None #4835

Closed
@xavierog

Description

@xavierog

Overall, ProgressBar is not a CPU-greedy widget. It does bring a small yet noticeable increase in CPU consumption when left in "indeterminate" mode since this mode involves a sliding animation. As far as I can tell, this is both normal and acceptable.

However, I noticed this CPU consumption does not decrease when the progress bar is hidden (e.g. self.progress_bar.styles.display = 'none'). This could be improved by adjusting Bar.auto_refresh whenever necessary.

Currently, Bar.auto_refresh only reacts to changes of the percentage attribute:

def watch_percentage(self, percentage: float | None) -> None:
"""Manage the timer that enables the indeterminate bar animation."""
if percentage is not None:
self.auto_refresh = None
else:
self.auto_refresh = 1 / 15

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions