@@ -94,19 +94,19 @@ def __init__(
94
94
self ._label = label
95
95
self .body = self .fill = self .shadow = None
96
96
97
- self .fill_color = _check_color (fill_color )
98
- self .outline_color = _check_color (outline_color )
97
+ self ._fill_color = _check_color (fill_color )
98
+ self ._outline_color = _check_color (outline_color )
99
99
self ._label_color = label_color
100
100
self ._label_font = label_font
101
101
# Selecting inverts the button colors!
102
- self .selected_fill = _check_color (selected_fill )
103
- self .selected_outline = _check_color (selected_outline )
104
- self .selected_label = _check_color (selected_label )
102
+ self ._selected_fill = _check_color (selected_fill )
103
+ self ._selected_outline = _check_color (selected_outline )
104
+ self ._selected_label = _check_color (selected_label )
105
105
106
106
if self .selected_fill is None and fill_color is not None :
107
- self .selected_fill = (~ self .fill_color ) & 0xFFFFFF
107
+ self .selected_fill = (~ self ._fill_color ) & 0xFFFFFF
108
108
if self .selected_outline is None and outline_color is not None :
109
- self .selected_outline = (~ self .outline_color ) & 0xFFFFFF
109
+ self .selected_outline = (~ self ._outline_color ) & 0xFFFFFF
110
110
111
111
if (outline_color is not None ) or (fill_color is not None ):
112
112
if style == Button .RECT :
@@ -115,8 +115,8 @@ def __init__(
115
115
0 ,
116
116
width ,
117
117
height ,
118
- fill = self .fill_color ,
119
- outline = self .outline_color ,
118
+ fill = self ._fill_color ,
119
+ outline = self ._outline_color ,
120
120
)
121
121
elif style == Button .ROUNDRECT :
122
122
self .body = RoundRect (
@@ -125,8 +125,8 @@ def __init__(
125
125
width ,
126
126
height ,
127
127
r = 10 ,
128
- fill = self .fill_color ,
129
- outline = self .outline_color ,
128
+ fill = self ._fill_color ,
129
+ outline = self ._outline_color ,
130
130
)
131
131
elif style == Button .SHADOWRECT :
132
132
self .shadow = Rect (2 , 2 , width - 2 , height - 2 , fill = outline_color )
@@ -135,21 +135,21 @@ def __init__(
135
135
0 ,
136
136
width - 2 ,
137
137
height - 2 ,
138
- fill = self .fill_color ,
139
- outline = self .outline_color ,
138
+ fill = self ._fill_color ,
139
+ outline = self ._outline_color ,
140
140
)
141
141
elif style == Button .SHADOWROUNDRECT :
142
142
self .shadow = RoundRect (
143
- 2 , 2 , width - 2 , height - 2 , r = 10 , fill = self .outline_color
143
+ 2 , 2 , width - 2 , height - 2 , r = 10 , fill = self ._outline_color
144
144
)
145
145
self .body = RoundRect (
146
146
0 ,
147
147
0 ,
148
148
width - 2 ,
149
149
height - 2 ,
150
150
r = 10 ,
151
- fill = self .fill_color ,
152
- outline = self .outline_color ,
151
+ fill = self ._fill_color ,
152
+ outline = self ._outline_color ,
153
153
)
154
154
if self .shadow :
155
155
self .append (self .shadow )
@@ -200,10 +200,10 @@ def selected(self, value):
200
200
new_out = self .selected_outline
201
201
new_label = self .selected_label
202
202
else :
203
- new_fill = self .fill_color
204
- new_out = self .outline_color
203
+ new_fill = self ._fill_color
204
+ new_out = self ._outline_color
205
205
new_label = self ._label_color
206
- # update all relevant colros !
206
+ # update all relevant colors !
207
207
if self .body is not None :
208
208
self .body .fill = new_fill
209
209
self .body .outline = new_out
@@ -228,3 +228,66 @@ def contains(self, point):
228
228
return (self .x <= point [0 ] <= self .x + self .width ) and (
229
229
self .y <= point [1 ] <= self .y + self .height
230
230
)
231
+
232
+ @property
233
+ def fill_color (self ):
234
+ """The fill color of the button body"""
235
+ return self ._fill_color
236
+
237
+ @fill_color .setter
238
+ def fill_color (self , new_color ):
239
+ self ._fill_color = _check_color (new_color )
240
+ if not self .selected :
241
+ self .body .fill = self ._fill_color
242
+
243
+ @property
244
+ def outline_color (self ):
245
+ """The outline color of the button body"""
246
+ return self ._outline_color
247
+
248
+ @outline_color .setter
249
+ def outline_color (self , new_color ):
250
+ self ._outline_color = _check_color (new_color )
251
+ if not self .selected :
252
+ self .body .outline = self ._outline_color
253
+
254
+ @property
255
+ def selected_fill (self ):
256
+ """The fill color of the button body when selected"""
257
+ return self ._selected_fill
258
+
259
+ @selected_fill .setter
260
+ def selected_fill (self , new_color ):
261
+ self ._selected_fill = _check_color (new_color )
262
+ if self .selected :
263
+ self .body .fill = self ._selected_fill
264
+
265
+ @property
266
+ def selected_outline (self ):
267
+ """The outline color of the button body when selected"""
268
+ return self ._selected_outline
269
+
270
+ @selected_outline .setter
271
+ def selected_outline (self , new_color ):
272
+ self ._selected_outline = _check_color (new_color )
273
+ if self .selected :
274
+ self .body .outline = self ._selected_outline
275
+
276
+ @property
277
+ def selected_label (self ):
278
+ """The font color of the button when selected"""
279
+ return self ._selected_label
280
+
281
+ @selected_label .setter
282
+ def selected_label (self , new_color ):
283
+ self ._selected_label = _check_color (new_color )
284
+
285
+ @property
286
+ def label_color (self ):
287
+ """The font color of the button"""
288
+ return self ._label_color
289
+
290
+ @label_color .setter
291
+ def label_color (self , new_color ):
292
+ self ._label_color = _check_color (new_color )
293
+ self ._label .color = self ._label_color
0 commit comments