From c87a75fba29050bf082ed7983381e95d54b41831 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Fri, 13 Nov 2020 16:19:00 -0800 Subject: [PATCH 1/3] Fix description of text_maxlen --- adafruit_magtag/magtag.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/adafruit_magtag/magtag.py b/adafruit_magtag/magtag.py index 2c1e846..7f35f59 100755 --- a/adafruit_magtag/magtag.py +++ b/adafruit_magtag/magtag.py @@ -110,6 +110,7 @@ def __init__( self._text_scale = [] self._text_font = [] self._text_line_spacing = [] + self._text_fetch_update = [] gc.collect() @@ -124,6 +125,7 @@ def add_text( text_transform=None, text_scale=1, line_spacing=1.25, + update_on_fetch=True, ): """ Add text labels with settings @@ -136,9 +138,11 @@ def add_text( when there's multiple texts. Defaults to ``None``. :param text_wrap: Whether or not to wrap text (for long text data chunks). Defaults to ``False``, no wrapping. - :param text_maxlen: The max length of the text for text wrapping. Defaults to 0. + :param text_maxlen: The max length of the text. If non-zero, it will be truncated to this + length. Defaults to 0. :param text_transform: A function that will be called on the text before display :param int text_scale: The factor to scale the default size of the text by + :param bool update_on_fetch: When ``True``, fetch_data() will automatically update the text """ if text_font is terminalio.FONT: self._text_font.append(text_font) @@ -165,6 +169,7 @@ def add_text( self._text_transform.append(text_transform) self._text_scale.append(text_scale) self._text_line_spacing.append(line_spacing) + self._text_fetch_update.append(update_on_fetch) # pylint: enable=too-many-arguments @@ -334,6 +339,10 @@ def fetch(self, refresh_url=None, timeout=10): timeout=timeout, ) + """ + Loop through the text blocks and create a list of indexes to update + """ + # fill out all the text blocks if self._text: for i in range(len(self._text)): From a1cc77a2787d39fa1bb4eb18b830fc542f346a0b Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Fri, 13 Nov 2020 16:21:14 -0800 Subject: [PATCH 2/3] Remove hacky code updates --- adafruit_magtag/magtag.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/adafruit_magtag/magtag.py b/adafruit_magtag/magtag.py index 7f35f59..bc506e6 100755 --- a/adafruit_magtag/magtag.py +++ b/adafruit_magtag/magtag.py @@ -110,7 +110,6 @@ def __init__( self._text_scale = [] self._text_font = [] self._text_line_spacing = [] - self._text_fetch_update = [] gc.collect() @@ -125,7 +124,6 @@ def add_text( text_transform=None, text_scale=1, line_spacing=1.25, - update_on_fetch=True, ): """ Add text labels with settings @@ -142,7 +140,6 @@ def add_text( length. Defaults to 0. :param text_transform: A function that will be called on the text before display :param int text_scale: The factor to scale the default size of the text by - :param bool update_on_fetch: When ``True``, fetch_data() will automatically update the text """ if text_font is terminalio.FONT: self._text_font.append(text_font) @@ -169,7 +166,6 @@ def add_text( self._text_transform.append(text_transform) self._text_scale.append(text_scale) self._text_line_spacing.append(line_spacing) - self._text_fetch_update.append(update_on_fetch) # pylint: enable=too-many-arguments @@ -339,10 +335,6 @@ def fetch(self, refresh_url=None, timeout=10): timeout=timeout, ) - """ - Loop through the text blocks and create a list of indexes to update - """ - # fill out all the text blocks if self._text: for i in range(len(self._text)): From eeacab662a8956f3964f15afb7a1274728b2483a Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Fri, 13 Nov 2020 16:34:28 -0800 Subject: [PATCH 3/3] Fix text_wrap description and default val --- adafruit_magtag/magtag.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/adafruit_magtag/magtag.py b/adafruit_magtag/magtag.py index bc506e6..7d705ae 100755 --- a/adafruit_magtag/magtag.py +++ b/adafruit_magtag/magtag.py @@ -119,7 +119,7 @@ def add_text( text_position=(0, 0), text_font=terminalio.FONT, text_color=0x000000, - text_wrap=False, + text_wrap=0, text_maxlen=0, text_transform=None, text_scale=1, @@ -134,8 +134,8 @@ def add_text( example. :param text_color: The color of the text, in 0xRRGGBB format. Can be a list of colors for when there's multiple texts. Defaults to ``None``. - :param text_wrap: Whether or not to wrap text (for long text data chunks). Defaults to - ``False``, no wrapping. + :param text_wrap: When non-zero, the maximum number of characters on each line before text + is wrapped. (for long text data chunks). Defaults to 0, no wrapping. :param text_maxlen: The max length of the text. If non-zero, it will be truncated to this length. Defaults to 0. :param text_transform: A function that will be called on the text before display