@@ -112,6 +112,7 @@ def __init__(
112112 self ._text_font = []
113113 self ._text_line_spacing = []
114114 self ._text_anchor_point = []
115+ self ._text_is_data = []
115116
116117 gc .collect ()
117118
@@ -127,6 +128,7 @@ def add_text(
127128 text_scale = 1 ,
128129 line_spacing = 1.25 ,
129130 text_anchor_point = (0 , 0.5 ),
131+ is_data = True ,
130132 ):
131133 """
132134 Add text labels with settings
@@ -143,6 +145,10 @@ def add_text(
143145 length. Defaults to 0.
144146 :param text_transform: A function that will be called on the text before display
145147 :param int text_scale: The factor to scale the default size of the text by
148+ :param float line_spacing: The factor to space the lines apart
149+ :param (float, float) text_anchor_point: Values between 0 and 1 to indicate where the text
150+ position is relative to the label
151+ :param bool is_data: If True, fetch will attempt to update the label
146152 """
147153 if text_font is terminalio .FONT :
148154 self ._text_font .append (text_font )
@@ -174,6 +180,7 @@ def add_text(
174180 self ._text_scale .append (text_scale )
175181 self ._text_line_spacing .append (line_spacing )
176182 self ._text_anchor_point .append (text_anchor_point )
183+ self ._text_is_data .append (bool (is_data ))
177184
178185 # pylint: enable=too-many-arguments
179186
@@ -358,17 +365,21 @@ def fetch(self, refresh_url=None, timeout=10):
358365
359366 # fill out all the text blocks
360367 if self ._text :
368+ value_index = 0 # In case values and text is not the same
361369 for i in range (len (self ._text )):
370+ if not self ._text_is_data [i ]:
371+ continue
362372 string = None
363373 if self ._text_transform [i ]:
364374 func = self ._text_transform [i ]
365- string = func (values [i ])
375+ string = func (values [value_index ])
366376 else :
367377 try :
368- string = "{:,d}" .format (int (values [i ]))
378+ string = "{:,d}" .format (int (values [value_index ]))
369379 except (TypeError , ValueError ):
370- string = values [i ] # ok its a string
380+ string = values [value_index ] # ok its a string
371381 self .set_text (string , index = i , auto_refresh = False )
382+ value_index += 1
372383 self .refresh ()
373384 if len (values ) == 1 :
374385 return values [0 ]
0 commit comments