@@ -108,15 +108,16 @@ def __init__(
108
108
):
109
109
110
110
# initialize the Widget superclass (x, y, scale)
111
- super ().__init__ (** kwargs , max_size = 4 )
111
+ super ().__init__ (** kwargs , max_size = 5 )
112
112
# Define how many graphical elements will be in this group
113
113
# using "max_size=XX"
114
114
#
115
115
# Group elements for SwitchRoundHorizontal:
116
116
# 1. switch_roundrect: The switch background
117
117
# 2. switch_circle: The switch button
118
118
# 3. Optional - widget label
119
- # 4. Optional - text_0 or text_1: The 0/1 text on the switch button
119
+ # 4. Optional: text_0: The "0" circle on the switch button
120
+ # 5. Optional: text_1: The "1" rectangle on the switch button
120
121
121
122
# initialize the Control superclass
122
123
super (Control , self ).__init__ ()
@@ -160,8 +161,6 @@ def __init__(
160
161
161
162
self ._value = value
162
163
163
- self ._text_0_on = not value # controls which text value is displayed (0 or 1)
164
-
165
164
self ._anchor_point = anchor_point
166
165
self ._anchored_position = anchored_position
167
166
@@ -315,10 +314,14 @@ def __init__(
315
314
316
315
# If display_button_text is True, append the correct text element (0 or 1)
317
316
if display_button_text :
318
- if self ._text_0_on :
319
- self .append (self ._text_0 )
317
+ self .append (self ._text_0 )
318
+ self .append (self ._text_1 )
319
+ if self ._value :
320
+ self ._text_0 .hidden = True
321
+ self ._text_1 .hidden = False
320
322
else :
321
- self .append (self ._text_1 )
323
+ self ._text_0 .hidden = False
324
+ self ._text_1 .hidden = True
322
325
323
326
# update the position, if required
324
327
self ._update_position ()
@@ -386,15 +389,13 @@ def _draw_position(self, position):
386
389
self ._text_0 .outline = self ._switch_circle .outline
387
390
self ._text_1 .outline = self ._switch_circle .outline
388
391
389
- if self ._display_button_text and position > 0.5 and self ._text_0_on :
390
- self .pop ()
391
- self .append (self ._text_1 )
392
- self ._text_0_on = False
392
+ if self ._display_button_text and position >= 0.5 :
393
+ self ._text_0 .hidden = True
394
+ self ._text_1 .hidden = False
393
395
394
- elif self ._display_button_text and position < 0.5 and not self ._text_0_on :
395
- self .pop ()
396
- self .append (self ._text_0 )
397
- self ._text_0_on = True
396
+ elif self ._display_button_text and position < 0.5 :
397
+ self ._text_0 .hidden = False
398
+ self ._text_1 .hidden = True
398
399
399
400
def selected (self , touch_point ):
400
401
# requires passing display to allow auto_refresh off when redrawing
0 commit comments