@@ -94,19 +94,19 @@ def __init__(
9494 self ._label = label
9595 self .body = self .fill = self .shadow = None
9696
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 )
9999 self ._label_color = label_color
100100 self ._label_font = label_font
101101 # 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 )
105105
106106 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
108108 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
110110
111111 if (outline_color is not None ) or (fill_color is not None ):
112112 if style == Button .RECT :
@@ -115,8 +115,8 @@ def __init__(
115115 0 ,
116116 width ,
117117 height ,
118- fill = self .fill_color ,
119- outline = self .outline_color ,
118+ fill = self ._fill_color ,
119+ outline = self ._outline_color ,
120120 )
121121 elif style == Button .ROUNDRECT :
122122 self .body = RoundRect (
@@ -125,8 +125,8 @@ def __init__(
125125 width ,
126126 height ,
127127 r = 10 ,
128- fill = self .fill_color ,
129- outline = self .outline_color ,
128+ fill = self ._fill_color ,
129+ outline = self ._outline_color ,
130130 )
131131 elif style == Button .SHADOWRECT :
132132 self .shadow = Rect (2 , 2 , width - 2 , height - 2 , fill = outline_color )
@@ -135,21 +135,21 @@ def __init__(
135135 0 ,
136136 width - 2 ,
137137 height - 2 ,
138- fill = self .fill_color ,
139- outline = self .outline_color ,
138+ fill = self ._fill_color ,
139+ outline = self ._outline_color ,
140140 )
141141 elif style == Button .SHADOWROUNDRECT :
142142 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
144144 )
145145 self .body = RoundRect (
146146 0 ,
147147 0 ,
148148 width - 2 ,
149149 height - 2 ,
150150 r = 10 ,
151- fill = self .fill_color ,
152- outline = self .outline_color ,
151+ fill = self ._fill_color ,
152+ outline = self ._outline_color ,
153153 )
154154 if self .shadow :
155155 self .append (self .shadow )
@@ -200,10 +200,10 @@ def selected(self, value):
200200 new_out = self .selected_outline
201201 new_label = self .selected_label
202202 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
205205 new_label = self ._label_color
206- # update all relevant colros !
206+ # update all relevant colors !
207207 if self .body is not None :
208208 self .body .fill = new_fill
209209 self .body .outline = new_out
@@ -228,3 +228,66 @@ def contains(self, point):
228228 return (self .x <= point [0 ] <= self .x + self .width ) and (
229229 self .y <= point [1 ] <= self .y + self .height
230230 )
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