From c5ead1c65d487d1583988a9c18f305a5c175799b Mon Sep 17 00:00:00 2001 From: dbouget Date: Thu, 1 Sep 2022 09:11:28 +0200 Subject: [PATCH] Adjusted the circular progress bar. Closes #22, #27. [skip ci] --- .../ProcessProgressWidget.py | 2 +- gui2/UtilsWidgets/QCircularProgressBar.py | 29 ++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/gui2/SinglePatientComponent/ProcessProgressWidget.py b/gui2/SinglePatientComponent/ProcessProgressWidget.py index 164a304..64c95a5 100644 --- a/gui2/SinglePatientComponent/ProcessProgressWidget.py +++ b/gui2/SinglePatientComponent/ProcessProgressWidget.py @@ -82,7 +82,7 @@ def on_process_started(self): self.processing_steps = None self.progress_label.setText("Overall progress: ") - + self.circular_progressbar.reset() self.process_stages_stack = [] self.progress_widget = [] items = (self.detailed_progression_layout.itemAt(i) for i in reversed(range(self.detailed_progression_layout.count()))) diff --git a/gui2/UtilsWidgets/QCircularProgressBar.py b/gui2/UtilsWidgets/QCircularProgressBar.py index 28b6f3a..050efb0 100644 --- a/gui2/UtilsWidgets/QCircularProgressBar.py +++ b/gui2/UtilsWidgets/QCircularProgressBar.py @@ -23,6 +23,14 @@ def __set_stylesheets(self): self.text_color = QColor(67, 88, 90) def paintEvent(self, event: QPaintEvent) -> None: + """ + Repainting the widget fully everytime, the painter can only be called/accessed from within here. + + Parameters + ---------- + event: QPaintEvent + Qt internal painting event, not directly used. + """ pd = self.progress_ratio * 360 rd = 360 - pd painter = QPainter(self) @@ -60,10 +68,29 @@ def paintEvent(self, event: QPaintEvent) -> None: elif cast_perc < 100: painter.drawText(80, 124, self.display_progress) else: - painter.drawText(70, 124, self.display_progress) + painter.drawText(75, 124, self.display_progress) painter.end() + def reset(self): + """ + Repainting the widget with default values at the start of a new process. + """ + self.progress_ratio = 0. + self.display_header = "Progress: " + self.display_progress = "-%" + self.update() + def advance(self, current_step: int, total_steps: int) -> None: + """ + Advancing the progress of the widget by providing the newly reached step of a process. + + Parameters + ---------- + current_step: int + Value of the step currently performed by the ongoing process. + total_steps: int + Value of the total number of steps to be performed by the ongoing process. + """ self.progress_ratio = float(current_step/total_steps) cast_perc = int(self.progress_ratio * 100.) self.display_header = "Progress: {}/{}".format(current_step, total_steps)