From 112fa126f5c99ee837d984524988d0772a822efb Mon Sep 17 00:00:00 2001 From: FoamyGuy Date: Sat, 22 Aug 2020 14:02:35 -0500 Subject: [PATCH 1/2] make width and height public --- adafruit_progressbar.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/adafruit_progressbar.py b/adafruit_progressbar.py index c9fb609..350a234 100755 --- a/adafruit_progressbar.py +++ b/adafruit_progressbar.py @@ -80,8 +80,8 @@ def __init__( self._palette[1] = outline_color self._palette[2] = bar_color - self._width = width - self._height = height + self.width = width + self.height = height self._progress_val = 0.0 self.progress = self._progress_val @@ -119,17 +119,17 @@ def progress(self, value): if self._progress_val > value: # uncolorize range from width*value+margin to width-margin # from right to left - _prev_pixel = max(2, int(self._width * self._progress_val - 2)) - _new_pixel = max(int(self._width * value - 2), 2) + _prev_pixel = max(2, int(self.width * self._progress_val - 2)) + _new_pixel = max(int(self.width * value - 2), 2) for _w in range(_prev_pixel, _new_pixel - 1, -1): - for _h in range(2, self._height - 2): + for _h in range(2, self.height - 2): self._bitmap[_w, _h] = 0 else: # fill from the previous x pixel to the new x pixel - _prev_pixel = max(2, int(self._width * self._progress_val - 3)) - _new_pixel = min(int(self._width * value - 2), int(self._width * 1.0 - 3)) + _prev_pixel = max(2, int(self.width * self._progress_val - 3)) + _new_pixel = min(int(self.width * value - 2), int(self.width * 1.0 - 3)) for _w in range(_prev_pixel, _new_pixel + 1): - for _h in range(2, self._height - 2): + for _h in range(2, self.height - 2): self._bitmap[_w, _h] = 2 self._progress_val = value From 6853d73e109d6a70504667f45cebfd43bcbc495a Mon Sep 17 00:00:00 2001 From: FoamyGuy Date: Mon, 24 Aug 2020 23:15:35 -0500 Subject: [PATCH 2/2] make width and height properties without setters. --- adafruit_progressbar.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/adafruit_progressbar.py b/adafruit_progressbar.py index 350a234..6af3b19 100755 --- a/adafruit_progressbar.py +++ b/adafruit_progressbar.py @@ -80,8 +80,8 @@ def __init__( self._palette[1] = outline_color self._palette[2] = bar_color - self.width = width - self.height = height + self._width = width + self._height = height self._progress_val = 0.0 self.progress = self._progress_val @@ -141,6 +141,20 @@ def fill(self): """ return self._palette[0] + @property + def width(self): + """The width of the progress bar. In pixels, includes the border. + + """ + return self._width + + @property + def height(self): + """The height of the progress bar. In pixels, includes the border. + + """ + return self._height + @fill.setter def fill(self, color): """Sets the fill of the progress bar. Can be a hex value for a color or ``None`` for