@@ -218,7 +218,7 @@ def preload_font(self, glyphs=None):
218
218
if not glyphs :
219
219
glyphs = b"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-!,. \" '?!"
220
220
print ("Preloading font glyphs:" , glyphs )
221
- if self ._text_font and self . _text_font is not terminalio .FONT :
221
+ if self ._text_font is not terminalio .FONT :
222
222
self ._text_font .load_glyphs (glyphs )
223
223
224
224
def set_text_color (self , color , index = 0 ):
@@ -243,36 +243,28 @@ def set_text(self, val, index=0):
243
243
# Make sure at least a single label exists
244
244
if not self ._text :
245
245
self .add_text ()
246
- if self ._text_font :
247
- string = str (val )
248
- if self ._text_maxlen [index ]:
249
- string = string [: self ._text_maxlen [index ]]
250
- if self ._text [index ]:
251
- # print("Replacing text area with :", string)
252
- # self._text[index].text = string
253
- # return
254
- try :
255
- text_index = self .splash .index (self ._text [index ])
256
- except AttributeError :
257
- for i in range (len (self .splash )):
258
- if self .splash [i ] == self ._text [index ]:
259
- text_index = i
260
- break
261
-
262
- self ._text [index ] = Label (self ._text_font , text = string )
263
- self ._text [index ].color = self ._text_color [index ]
264
- self ._text [index ].x = self ._text_position [index ][0 ]
265
- self ._text [index ].y = self ._text_position [index ][1 ]
266
- self .splash [text_index ] = self ._text [index ]
267
- return
268
-
269
- if self ._text_position [index ]: # if we want it placed somewhere...
270
- print ("Making text area with string:" , string )
271
- self ._text [index ] = Label (self ._text_font , text = string )
272
- self ._text [index ].color = self ._text_color [index ]
273
- self ._text [index ].x = self ._text_position [index ][0 ]
274
- self ._text [index ].y = self ._text_position [index ][1 ]
275
- self .splash .append (self ._text [index ])
246
+ string = str (val )
247
+ if not string :
248
+ max_glyphs = 50
249
+ else :
250
+ max_glyphs = len (string )
251
+ if self ._text_maxlen [index ]:
252
+ string = string [: self ._text_maxlen [index ]]
253
+ print ("text index" , self ._text [index ])
254
+ index_in_splash = None
255
+ if self ._text [index ] is not None :
256
+ print ("Replacing text area with :" , string )
257
+ self ._text [index ].text = string
258
+ index_in_splash = self .splash .index (self ._text [index ])
259
+ self ._text [index ] = Label (self ._text_font , text = string , max_glyphs = max_glyphs )
260
+ self ._text [index ].color = self ._text_color [index ]
261
+ self ._text [index ].x = self ._text_position [index ][0 ]
262
+ self ._text [index ].y = self ._text_position [index ][1 ]
263
+
264
+ if index_in_splash is not None :
265
+ self .splash [index_in_splash ] = self ._text [index ]
266
+ else :
267
+ self .splash .append (self ._text [index ])
276
268
277
269
def get_local_time (self , location = None ):
278
270
"""Accessor function for get_local_time()"""
0 commit comments