@@ -132,10 +132,6 @@ def __init__(
132
132
self ._bar_width = self ._width
133
133
self ._bar_height = self ._height
134
134
135
- self ._progress_val = 0.0
136
- self .progress = self ._progress_val
137
- self .progress = progress
138
-
139
135
self ._x = anchor_position [0 ]
140
136
self ._y = anchor_position [1 ]
141
137
@@ -153,64 +149,24 @@ def __init__(
153
149
value_range = (0.0 , 1.0 ),
154
150
)
155
151
156
- self ._draw_outline ()
157
-
158
- def _draw_outline (self ):
159
- """
160
- Draws the outline (border) of the widget.
161
- """
162
-
163
- # draw outline rectangle
164
- for _w in range (self ._width ):
165
- for line in range (self ._stroke ):
166
- self ._bitmap [_w , line ] = 1
167
- self ._bitmap [_w , self ._height - 1 - line ] = 1
168
- for _h in range (self ._height ):
169
- for line in range (self ._stroke ):
170
- self ._bitmap [line , _h ] = 1
171
- self ._bitmap [self ._width - 1 - line , _h ] = 1
172
-
173
- @property
174
- def progress (self ):
175
- """The percentage of the progress bar expressed as a
176
- floating point number.
177
- """
178
- return self ._progress_val
179
-
180
- # pylint: disable=too-many-locals
181
- @progress .setter
182
- def progress (self , value ):
183
- """Draws the progress bar
184
-
185
- :param value: Progress bar value.
186
- :type value: float
187
- """
188
- assert value <= self ._max , "Progress value may not be > maximum value"
189
- assert value >= self ._min , "Progress value may not be < minimum value"
190
-
191
- _old_value = self ._progress_val
192
- _new_value = round (value / self ._max , 2 )
193
- self ._progress_val = _new_value
194
- self .render (_old_value , _new_value , value )
195
-
196
- def render (self , old_value , new_value , progress ):
152
+ def render (self , _old_value , _new_value , _progress_value ):
197
153
"""
198
154
Does the work of actually creating the graphical representation of
199
155
the value (percentage, aka "progress") to be displayed.
200
156
201
- :param old_value : The previously displayed value
202
- :type old_value : float
203
- :param new_value : The new value to display
204
- :type new_value : float
205
- :param progress : The value to display, as a percentage, represented
157
+ :param _old_value : The previously displayed value
158
+ :type _old_value : float
159
+ :param _new_value : The new value to display
160
+ :type _new_value : float
161
+ :param _progress_value : The value to display, as a percentage, represented
206
162
by a float from 0.0 to 1.0 (0% to 100%)
207
- :type progress : float
163
+ :type _progress_value : float
208
164
:return: None
209
165
:rtype: None
210
166
"""
211
167
_padding = 0
212
168
213
- print (f"Drawing a visual of progress value { progress } " )
169
+ print (f"Drawing a visual of progress value { _progress_value } " )
214
170
215
171
if self ._margin :
216
172
_padding = 1
@@ -222,24 +178,24 @@ def render(self, old_value, new_value, progress):
222
178
# in both directions (left-to-right and top-to-bottom)
223
179
224
180
_fill_width = (
225
- self .width - (2 * _padding ) - _border_size
181
+ self .widget_width - (2 * _padding ) - _border_size
226
182
) # Count padding on left and right
227
183
_fill_height = (
228
- self .height - (2 * _padding ) - _border_size
184
+ self .widget_height - (2 * _padding ) - _border_size
229
185
) # Count padding on the top and bottom
230
186
231
- _prev_value_size = int (old_value * _fill_height )
232
- _new_value_size = int (new_value * _fill_height )
187
+ _prev_value_size = int (_old_value * _fill_height )
188
+ _new_value_size = int (_new_value * _fill_height )
233
189
234
190
# If we have *ANY* value other than "zero" (minimum), we should
235
191
# have at least one element showing
236
- if _new_value_size == 0 and new_value > self ._min :
192
+ if _new_value_size == 0 and _new_value > self ._min :
237
193
_new_value_size = 1
238
194
239
195
# Conversely, if we have *ANY* value other than 100% (maximum),
240
196
# we should NOT show a full bar.
241
197
242
- if _new_value_size == _fill_height and new_value < self ._max :
198
+ if _new_value_size == _fill_height and _new_value < self ._max :
243
199
_new_value_size -= 1
244
200
245
201
# Default values for increasing value
@@ -269,32 +225,3 @@ def render(self, old_value, new_value, progress):
269
225
for h in range (_start , _end , _incr ):
270
226
for w in range (_start_offset , _fill_width ):
271
227
self ._bitmap [w , h ] = _color
272
-
273
- @property
274
- def fill (self ):
275
- """The fill of the progress bar. Can be a hex value for a color or
276
- ``None`` for transparent.
277
- """
278
- return self ._palette [0 ]
279
-
280
- @property
281
- def width (self ):
282
- """The width of the progress bar. In pixels, includes the border."""
283
- return self ._bar_width
284
-
285
- @property
286
- def height (self ):
287
- """The height of the progress bar. In pixels, includes the border."""
288
- return self ._bar_height
289
-
290
- @fill .setter
291
- def fill (self , color ):
292
- """Sets the fill of the progress bar. Can be a hex value for a color or
293
- ``None`` for transparent.
294
- """
295
- if color is None :
296
- self ._palette [2 ] = 0
297
- self ._palette .make_transparent (0 )
298
- else :
299
- self ._palette [2 ] = color
300
- self ._palette .make_opaque (0 )
0 commit comments