diff --git a/CHANGELOG.md b/CHANGELOG.md index ab6c6d4c2d4..1af1ce81c4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Breaking change: Widget.notify and App.notify now return None https://github.com/Textualize/textual/pull/3275 - App.unnotify is now private (renamed to App._unnotify) https://github.com/Textualize/textual/pull/3275 - `Markdown.load` will now attempt to scroll to a related heading if an anchor is provided https://github.com/Textualize/textual/pull/3244 +- `ProgressBar` explicitly supports being set back to its indeterminate state https://github.com/Textualize/textual/pull/3285 ## [0.36.0] - 2023-09-05 diff --git a/src/textual/widgets/_progress_bar.py b/src/textual/widgets/_progress_bar.py index 617d3908924..b0500bd9895 100644 --- a/src/textual/widgets/_progress_bar.py +++ b/src/textual/widgets/_progress_bar.py @@ -276,7 +276,6 @@ class ProgressBar(Widget, can_focus=False): """The total number of steps associated with this progress bar, when known. The value `None` will render an indeterminate progress bar. - Once `total` is set to a numerical value, it cannot be set back to `None`. """ percentage: reactive[float | None] = reactive[Optional[float]](None) """The percentage of progress that has been completed. @@ -398,6 +397,7 @@ def advance(self, advance: float = 1) -> None: ```py progress_bar.advance(10) # Advance 10 steps. ``` + Args: advance: Number of steps to advance progress by. """ diff --git a/tests/test_progress_bar.py b/tests/test_progress_bar.py index 64b034817d4..17771e40585 100644 --- a/tests/test_progress_bar.py +++ b/tests/test_progress_bar.py @@ -78,9 +78,6 @@ def test_update_total(): pb.update(total=1000) assert pb.total == 1000 - pb.update(total=None) - assert pb.total == 1000 - pb.update(total=100) assert pb.total == 100 @@ -119,6 +116,15 @@ def test_update(): assert pb.progress == 50 +def test_go_back_to_indeterminate(): + pb = ProgressBar() + + pb.total = 100 + assert pb.percentage == 0 + pb.total = None + assert pb.percentage is None + + @pytest.mark.parametrize( ["show_bar", "show_percentage", "show_eta"], [