@@ -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,60 @@ 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
+ self .body .fill = self ._fill_color
241
+
242
+ @property
243
+ def outline_color (self ):
244
+ """The outline color of the button body"""
245
+ return self ._outline_color
246
+
247
+ @outline_color .setter
248
+ def outline_color (self , new_color ):
249
+ self ._outline_color = _check_color (new_color )
250
+ self .body .outline = self ._outline_color
251
+
252
+ @property
253
+ def selected_fill (self ):
254
+ """The fill color of the button body when selected"""
255
+ return self ._selected_fill
256
+
257
+ @selected_fill .setter
258
+ def selected_fill (self , new_color ):
259
+ self ._selected_fill = _check_color (new_color )
260
+
261
+ @property
262
+ def selected_outline (self ):
263
+ """The outline color of the button body when selected"""
264
+ return self ._selected_outline
265
+
266
+ @selected_outline .setter
267
+ def selected_outline (self , new_color ):
268
+ self ._selected_outline = _check_color (new_color )
269
+
270
+ @property
271
+ def selected_label (self ):
272
+ """The font color of the button when selected"""
273
+ return self ._selected_label
274
+
275
+ @selected_label .setter
276
+ def selected_label (self , new_color ):
277
+ self ._selected_label = _check_color (new_color )
278
+
279
+ @property
280
+ def label_color (self ):
281
+ """The font color of the button"""
282
+ return self ._label_color
283
+
284
+ @label_color .setter
285
+ def label_color (self , new_color ):
286
+ self ._label_color = _check_color (new_color )
287
+ self ._label .color = self ._label_color
0 commit comments