3
3
# SPDX-License-Identifier: MIT
4
4
5
5
"""
6
- Display Text module helper functions
6
+ `adafruit_display_text`
7
+ =======================
7
8
"""
9
+
8
10
try :
9
- from typing import Tuple
11
+ from typing import List , Tuple
10
12
except ImportError :
11
13
pass
12
14
from displayio import Group , Palette
13
15
14
16
15
17
def wrap_text_to_pixels (
16
18
string : str , max_width : int , font = None , indent0 : str = "" , indent1 : str = ""
17
- ) -> None :
19
+ ) -> List [ str ] :
18
20
"""wrap_text_to_pixels function
19
21
A helper that will return a list of lines with word-break wrapping.
20
22
Leading and trailing whitespace in your string will be removed. If
21
- you wish to use leading whitespace see `indend0` and `indent1`
23
+ you wish to use leading whitespace see ``indent0`` and `` indent1` `
22
24
parameters.
23
25
24
26
:param str string: The text to be wrapped.
@@ -27,9 +29,9 @@ def wrap_text_to_pixels(
27
29
:param str indent0: Additional character(s) to add to the first line.
28
30
:param str indent1: Additional character(s) to add to all other lines.
29
31
30
-
31
- :return list lines: A list of the lines resulting from wrapping the
32
- input text at max_width pixels size
32
+ :return: A list of the lines resulting from wrapping the
33
+ input text at ``max_width`` pixels size
34
+ :rtype: List[str]
33
35
34
36
"""
35
37
# pylint: disable=too-many-locals, too-many-branches
@@ -100,16 +102,16 @@ def measure(string):
100
102
return lines
101
103
102
104
103
- def wrap_text_to_lines (string , max_chars ) :
105
+ def wrap_text_to_lines (string : str , max_chars : int ) -> List [ str ] :
104
106
"""wrap_text_to_lines function
105
107
A helper that will return a list of lines with word-break wrapping
106
108
107
109
:param str string: The text to be wrapped
108
110
:param int max_chars: The maximum number of characters on a line before wrapping
109
111
110
- :return list the_lines : A list of lines where each line is separated based on the amount
111
- of max_chars provided
112
-
112
+ :return: A list of lines where each line is separated based on the amount
113
+ of `` max_chars`` provided
114
+ :rtype: List[str]
113
115
"""
114
116
115
117
def chunks (lst , n ):
@@ -151,21 +153,23 @@ def chunks(lst, n):
151
153
152
154
153
155
class LabelBase (Group ):
154
- """Super class that all other types of labels will extend. This contains
156
+ """Superclass that all other types of labels will extend. This contains
155
157
all of the properties and functions that work the same way in all labels.
156
158
157
- subclasses should implement _set_text, _set_font, and _set_line_spacing to
158
- have the correct behavior fo rthat type of label.
159
+ **Note:** This should be treated as an abstract base class.
160
+
161
+ Subclasses should implement ``_set_text``, ``_set_font``, and ``_set_line_spacing`` to
162
+ have the correct behavior for that type of label.
159
163
160
164
:param Font font: A font class that has ``get_bounding_box`` and ``get_glyph``.
161
165
Must include a capital M for measuring character size.
162
166
:param str text: Text to display
163
167
:param int max_glyphs: Unnecessary parameter (provided only for direct compability
164
- with label.py )
168
+ with :py:func:`~adafruit_display_text. label.Label` )
165
169
:param int color: Color of all text in RGB hex
166
170
:param int background_color: Color of the background, use `None` for transparent
167
- :param double line_spacing: Line spacing of text to display
168
- :param boolean background_tight: Set `True` only if you want background box to tightly
171
+ :param float line_spacing: Line spacing of text to display
172
+ :param bool background_tight: Set `True` only if you want background box to tightly
169
173
surround text. When set to 'True' Padding parameters will be ignored.
170
174
:param int padding_top: Additional pixels added to background bounding box at top
171
175
:param int padding_bottom: Additional pixels added to background bounding box at bottom
0 commit comments