@@ -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,60 @@ 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+ 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