Skip to content

Commit 2dde38e

Browse files
authored
Merge pull request #16 from FoamyGuy/public_width_and_height
make width and height public
2 parents 2fb1bd1 + 6853d73 commit 2dde38e

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

adafruit_progressbar.py

+20-6
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,17 @@ def progress(self, value):
119119
if self._progress_val > value:
120120
# uncolorize range from width*value+margin to width-margin
121121
# from right to left
122-
_prev_pixel = max(2, int(self._width * self._progress_val - 2))
123-
_new_pixel = max(int(self._width * value - 2), 2)
122+
_prev_pixel = max(2, int(self.width * self._progress_val - 2))
123+
_new_pixel = max(int(self.width * value - 2), 2)
124124
for _w in range(_prev_pixel, _new_pixel - 1, -1):
125-
for _h in range(2, self._height - 2):
125+
for _h in range(2, self.height - 2):
126126
self._bitmap[_w, _h] = 0
127127
else:
128128
# fill from the previous x pixel to the new x pixel
129-
_prev_pixel = max(2, int(self._width * self._progress_val - 3))
130-
_new_pixel = min(int(self._width * value - 2), int(self._width * 1.0 - 3))
129+
_prev_pixel = max(2, int(self.width * self._progress_val - 3))
130+
_new_pixel = min(int(self.width * value - 2), int(self.width * 1.0 - 3))
131131
for _w in range(_prev_pixel, _new_pixel + 1):
132-
for _h in range(2, self._height - 2):
132+
for _h in range(2, self.height - 2):
133133
self._bitmap[_w, _h] = 2
134134
self._progress_val = value
135135

@@ -141,6 +141,20 @@ def fill(self):
141141
"""
142142
return self._palette[0]
143143

144+
@property
145+
def width(self):
146+
"""The width of the progress bar. In pixels, includes the border.
147+
148+
"""
149+
return self._width
150+
151+
@property
152+
def height(self):
153+
"""The height of the progress bar. In pixels, includes the border.
154+
155+
"""
156+
return self._height
157+
144158
@fill.setter
145159
def fill(self, color):
146160
"""Sets the fill of the progress bar. Can be a hex value for a color or ``None`` for

0 commit comments

Comments
 (0)