Skip to content

Commit

Permalink
Adjusted the circular progress bar. Closes #22, #27. [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
dbouget committed Sep 1, 2022
1 parent c01b9e7 commit c5ead1c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gui2/SinglePatientComponent/ProcessProgressWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())))
Expand Down
29 changes: 28 additions & 1 deletion gui2/UtilsWidgets/QCircularProgressBar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c5ead1c

Please sign in to comment.