@@ -237,24 +237,36 @@ def set_text(self, val, index=0):
237
237
index_in_splash = self .splash .index (self ._text [index ]["label" ])
238
238
elif self ._debug :
239
239
print ("Creating text area with :" , string )
240
+ if len (string ) > 0 :
241
+ # If longer text, destroy and recreate the label because we can't increase max_glyphs
242
+ if (
243
+ self ._text [index ]["label" ] is not None
244
+ and len (string ) > self ._text [index ]["label" ].width
245
+ ):
246
+ self ._text [index ]["label" ] = None
240
247
241
- if len (string .strip ()) > 0 :
242
248
if self ._text [index ]["label" ] is None :
243
249
self ._text [index ]["label" ] = Label (
244
250
self ._fonts [self ._text [index ]["font" ]],
245
251
text = string ,
246
252
scale = self ._text [index ]["scale" ],
247
253
)
254
+ if index_in_splash is not None :
255
+ self .splash [index_in_splash ] = self ._text [index ]["label" ]
256
+ else :
257
+ self .splash .append (self ._text [index ]["label" ])
258
+ else :
259
+ self ._text [index ]["label" ].text = string
248
260
self ._text [index ]["label" ].color = self ._text [index ]["color" ]
249
261
self ._text [index ]["label" ].anchor_point = self ._text [index ]["anchor_point" ]
250
262
self ._text [index ]["label" ].anchored_position = self ._text [index ]["position" ]
251
263
self ._text [index ]["label" ].line_spacing = self ._text [index ]["line_spacing" ]
252
264
elif index_in_splash is not None :
253
265
self ._text [index ]["label" ] = None
254
- del self .splash [index_in_splash ]
255
266
256
- if self ._text [index ]["label" ] is not None and index_in_splash is None :
257
- self .splash .append (self ._text [index ]["label" ])
267
+ # Remove the label from splash
268
+ if index_in_splash is not None and self ._text [index ]["label" ] is None :
269
+ del self .splash [index_in_splash ]
258
270
259
271
def preload_font (self , glyphs = None , index = 0 ):
260
272
# pylint: disable=line-too-long
0 commit comments