From 8f31302e2266f51bc5ce416f83abe3e7e9a3fd31 Mon Sep 17 00:00:00 2001 From: Jose Tiago Macara Coutinho Date: Mon, 24 Feb 2020 14:51:10 +0100 Subject: [PATCH] Add set_items_completed() to ProgressBarCounter --- prompt_toolkit/shortcuts/progress_bar/base.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/prompt_toolkit/shortcuts/progress_bar/base.py b/prompt_toolkit/shortcuts/progress_bar/base.py index b6afeae0e..c81c376e4 100644 --- a/prompt_toolkit/shortcuts/progress_bar/base.py +++ b/prompt_toolkit/shortcuts/progress_bar/base.py @@ -366,6 +366,11 @@ def item_completed(self, n: int = 1) -> None: self.items_completed += n self.progress_bar.invalidate() + def set_items_completed(self, nb_items: int) -> None: + if nb_items != self.items_completed: + self.items_completed = nb_items + self.progress_bar.invalidate() + @property def done(self) -> bool: """Whether a counter has been completed.