@@ -100,14 +100,13 @@ def __init__(
100
100
selected_outline = None ,
101
101
selected_label = None
102
102
):
103
- super ().__init__ ()
103
+ super ().__init__ (x = x , y = y )
104
104
self .x = x
105
105
self .y = y
106
106
self .width = width
107
107
self .height = height
108
108
self ._font = label_font
109
109
self ._selected = False
110
- self .group = displayio .Group ()
111
110
self .name = name
112
111
self ._label = label
113
112
self .body = self .fill = self .shadow = None
@@ -129,17 +128,17 @@ def __init__(
129
128
if (outline_color is not None ) or (fill_color is not None ):
130
129
if style == Button .RECT :
131
130
self .body = Rect (
132
- x ,
133
- y ,
131
+ 0 ,
132
+ 0 ,
134
133
width ,
135
134
height ,
136
135
fill = self .fill_color ,
137
136
outline = self .outline_color ,
138
137
)
139
138
elif style == Button .ROUNDRECT :
140
139
self .body = RoundRect (
141
- x ,
142
- y ,
140
+ 0 ,
141
+ 0 ,
143
142
width ,
144
143
height ,
145
144
r = 10 ,
@@ -148,32 +147,32 @@ def __init__(
148
147
)
149
148
elif style == Button .SHADOWRECT :
150
149
self .shadow = Rect (
151
- x + 2 , y + 2 , width - 2 , height - 2 , fill = outline_color
150
+ 0 + 2 , 0 + 2 , width - 2 , height - 2 , fill = outline_color
152
151
)
153
152
self .body = Rect (
154
- x ,
155
- y ,
153
+ 0 ,
154
+ 0 ,
156
155
width - 2 ,
157
156
height - 2 ,
158
157
fill = self .fill_color ,
159
158
outline = self .outline_color ,
160
159
)
161
160
elif style == Button .SHADOWROUNDRECT :
162
161
self .shadow = RoundRect (
163
- x + 2 , y + 2 , width - 2 , height - 2 , r = 10 , fill = self .outline_color
162
+ 0 + 2 , 0 + 2 , width - 2 , height - 2 , r = 10 , fill = self .outline_color
164
163
)
165
164
self .body = RoundRect (
166
- x ,
167
- y ,
165
+ 0 ,
166
+ 0 ,
168
167
width - 2 ,
169
168
height - 2 ,
170
169
r = 10 ,
171
170
fill = self .fill_color ,
172
171
outline = self .outline_color ,
173
172
)
174
173
if self .shadow :
175
- self .group . append (self .shadow )
176
- self .group . append (self .body )
174
+ self .append (self .shadow )
175
+ self .append (self .body )
177
176
178
177
self .label = label
179
178
@@ -184,8 +183,8 @@ def label(self):
184
183
185
184
@label .setter
186
185
def label (self , newtext ):
187
- if self ._label and self . group and (self . group [- 1 ] == self ._label ):
188
- self .group . pop ()
186
+ if self ._label and self and (self [- 1 ] == self ._label ):
187
+ self .pop ()
189
188
190
189
self ._label = None
191
190
if not newtext or (self ._label_color is None ): # no new text
@@ -197,10 +196,10 @@ def label(self, newtext):
197
196
dims = self ._label .bounding_box
198
197
if dims [2 ] >= self .width or dims [3 ] >= self .height :
199
198
raise RuntimeError ("Button not large enough for label" )
200
- self ._label .x = self . x + (self .width - dims [2 ]) // 2
201
- self ._label .y = self . y + self .height // 2
199
+ self ._label .x = 0 + (self .width - dims [2 ]) // 2
200
+ self ._label .y = 0 + self .height // 2
202
201
self ._label .color = self ._label_color
203
- self .group . append (self ._label )
202
+ self .append (self ._label )
204
203
205
204
if (self .selected_label is None ) and (self ._label_color is not None ):
206
205
self .selected_label = (~ self ._label_color ) & 0xFFFFFF
0 commit comments