@@ -65,9 +65,9 @@ class ProgressBarBase(displayio.TileGrid):
65
65
# pylint: disable=too-many-arguments
66
66
def __init__ (
67
67
self ,
68
- position : ( int , int ) ,
69
- size : ( int , int ) ,
70
- start_value : float = 0.0 ,
68
+ position ,
69
+ size ,
70
+ start_value = 0.0 ,
71
71
bar_color = 0x00FF00 ,
72
72
outline_color = 0xFFFFFF ,
73
73
fill_color = 0x000000 ,
@@ -76,10 +76,11 @@ def __init__(
76
76
value_range = (0.0 , 1.0 ),
77
77
):
78
78
79
- self ._size = size
79
+ self ._widget_size = size
80
80
self ._position = position
81
81
self ._progress = start_value
82
- self ._bitmap = displayio .Bitmap (self .width , self .height , 3 )
82
+ print (f"Size: { size } - WS: { self .widget_size } " )
83
+ self ._bitmap = displayio .Bitmap (size [0 ], size [1 ], 3 )
83
84
self ._palette = displayio .Palette (3 )
84
85
self ._palette [0 ] = fill_color
85
86
self ._palette [1 ] = outline_color
@@ -97,30 +98,36 @@ def __init__(
97
98
98
99
self ._draw_outline ()
99
100
100
- _bitmap : displayio .Bitmap # The bitmap used for the bar/value
101
- _position : (int , int ) # The (x,y) coordinates of the top-left corner
102
- _size : (int , int ) # The dimensions of the progress bar
103
- _palette : displayio .Palette (3 ) # The palette to be used
104
- _progress : float # The value to represent, between 0.0 and 100.0
105
- _border_thickness : int # The thickness of the border around the control, in pixels
106
- _show_margin : bool # Whether we should display a margin between the border and the value/bar
107
- # The minimum and maximum values we can represent
108
- _range : (int , int ) or (float , float )
101
+ # _bitmap: displayio.Bitmap # The bitmap used for the bar/value
102
+ # _position: (int, int) # The (x,y) coordinates of the top-left corner
103
+ # _widget_size: (int, int) # The dimensions of the progress bar
104
+ # _palette: displayio.Palette(3) # The palette to be used
105
+ # _progress: float # The value to represent, between 0.0 and 100.0
106
+ # _border_thickness: int # The thickness of the border around the control, in pixels
107
+ # _show_margin: bool # Whether we should display a margin between
108
+ # the border and the value/bar
109
+ # # The minimum and maximum values we can represent
110
+ # _range: (int, int) or (float, float)
109
111
110
112
@property
111
- def size (self ):
113
+ def widget_size (self ):
112
114
"""The size at the outer edge of the control, returned as a tuple (width, height)"""
113
- return self ._size
115
+ return self ._widget_size
114
116
115
117
@property
116
- def width (self ):
118
+ def widget_width (self ):
117
119
"""The total width of the widget, in pixels. Includes the border and margin."""
118
- return self .size [0 ]
120
+ return self .widget_size [0 ]
119
121
120
122
@property
121
- def height (self ):
123
+ def widget_height (self ):
122
124
"""The total height of the widget, in pixels. Includes the border and margin."""
123
- return self .size [1 ]
125
+ return self .widget_size [1 ]
126
+
127
+ @property
128
+ def _outline_color (self ):
129
+ """The colour of the border/outline of the widget"""
130
+ return self ._palette [1 ]
124
131
125
132
@property
126
133
def x (self ):
@@ -176,14 +183,14 @@ def _draw_outline(self):
176
183
stroke = self .border_thickness
177
184
178
185
# draw outline rectangle
179
- for _w in range (self .width ):
186
+ for _w in range (self .widget_width ):
180
187
for line in range (stroke ):
181
188
self ._bitmap [_w , line ] = 1
182
- self ._bitmap [_w , self .height - 1 - line ] = 1
183
- for _h in range (self .height ):
189
+ self ._bitmap [_w , self .widget_height - 1 - line ] = 1
190
+ for _h in range (self .widget_height ):
184
191
for line in range (stroke ):
185
192
self ._bitmap [line , _h ] = 1
186
- self ._bitmap [self .width - 1 - line , _h ] = 1
193
+ self ._bitmap [self .widget_width - 1 - line , _h ] = 1
187
194
188
195
def render (self , _old_value , _new_value , _progress_value ) -> None :
189
196
"""The method called when the display needs to be updated. This method
0 commit comments