Skip to content

Commit

Permalink
Merge pull request #663 from MyreMylar/progress-docs
Browse files Browse the repository at this point in the history
document progress bar methods/property
  • Loading branch information
MyreMylar authored Dec 30, 2024
2 parents a2fc015 + 44023b1 commit f4b101d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pygame_gui/elements/ui_progress_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,23 @@ def __init__(self,

@property
def progress_percentage(self):
"""
Get the current percentage progress of the bar from 0.0 to 1.0
:return: a float from 0.0 to 1.0
"""
return self.current_progress / self.maximum_progress

def status_text(self):
""" Subclass and override this method to change what text is displayed, or to suppress the text. """
return f"{self.current_progress:0.1f}/{self.maximum_progress:0.1f}"

def set_current_progress(self, progress: float):
"""
Set the current percentage progress of the bar
:param progress: a float from 0.0 to 100.0
"""
# Now that we subclass UIStatusBar, set_current_progress() and self.current_progress are mostly here for backward compatibility.
self.current_progress = progress

Expand Down

0 comments on commit f4b101d

Please sign in to comment.