Skip to content

Commit a08f833

Browse files
authored
Merge pull request #112 from jposada202020/updating-docs
Intial review of documentation
2 parents 2c2a403 + 6e35057 commit a08f833

File tree

1 file changed

+33
-10
lines changed

1 file changed

+33
-10
lines changed

adafruit_display_text/label.py

+33-10
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,27 @@ class Label(displayio.Group):
3939
:param str text: Text to display
4040
:param int max_glyphs: The largest quantity of glyphs we will display
4141
:param int color: Color of all text in RGB hex
42-
:param double line_spacing: Line spacing of text to display"""
42+
:param float line_spacing: Line spacing of text to display
43+
:param bool background_tight: Set `True` only if you want background box to tightly
44+
surround text. When set to 'True' Padding parameters will be ignored.
45+
:param int padding_top: Additional pixels added to background bounding box at top.
46+
This parameter could be negative indicating additional pixels subtracted to background
47+
bounding box.
48+
:param int padding_bottom: Additional pixels added to background bounding box at bottom.
49+
This parameter could be negative indicating additional pixels subtracted to background
50+
bounding box.
51+
:param int padding_left: Additional pixels added to background bounding box at left.
52+
This parameter could be negative indicating additional pixels subtracted to background
53+
bounding box.
54+
:param int padding_right: Additional pixels added to background bounding box at right.
55+
This parameter could be negative indicating additional pixels subtracted to background
56+
bounding box.
57+
:param (float,float) anchor_point: Point that anchored_position moves relative to.
58+
Tuple with decimal percentage of width and height.
59+
(E.g. (0,0) is top left, (1.0, 0.5): is middle right.)
60+
:param (int,int) anchored_position: Position relative to the anchor_point. Tuple
61+
containing x,y pixel coordinates.
62+
:param int scale: Integer value of the pixel scaling"""
4363

4464
# pylint: disable=too-many-instance-attributes, too-many-locals
4565
# This has a lot of getters/setters, maybe it needs cleanup.
@@ -74,12 +94,10 @@ def __init__(
7494
# instance the Group
7595
# self Group will contain a single local_group which contains a Group (self.local_group)
7696
# which contains a TileGrid
77-
super().__init__(
78-
max_size=1, scale=1, **kwargs
79-
) # The self scale should always be 1
80-
self.local_group = displayio.Group(
81-
max_size=max_glyphs + 1, scale=scale
82-
) # local_group will set the scale
97+
# The self scale should always be 1
98+
super().__init__(max_size=1, scale=1, **kwargs)
99+
# local_group will set the scale
100+
self.local_group = displayio.Group(max_size=max_glyphs + 1, scale=scale)
83101
self.append(self.local_group)
84102

85103
self.width = max_glyphs
@@ -120,6 +138,9 @@ def __init__(
120138
self.anchored_position = anchored_position
121139

122140
def _create_background_box(self, lines, y_offset):
141+
"""Private Class function to create a background_box
142+
:param lines: int number of lines
143+
:param y_offset: int y pixel bottom coordinate for the background_box"""
123144

124145
left = self._boundingbox[0]
125146

@@ -156,6 +177,7 @@ def _create_background_box(self, lines, y_offset):
156177
return tile_grid
157178

158179
def _get_ascent_descent(self):
180+
""" Private function to calculate ascent and descent font values """
159181
if hasattr(self.font, "ascent"):
160182
return self.font.ascent, self.font.descent
161183

@@ -179,6 +201,8 @@ def _get_ascent(self):
179201
return self._get_ascent_descent()[0]
180202

181203
def _update_background_color(self, new_color):
204+
"""Private class function that allows updating the font box background color
205+
:param new_color: int color as an RGB hex number."""
182206

183207
if new_color is None:
184208
self._background_palette.make_transparent(0)
@@ -204,9 +228,8 @@ def _update_background_color(self, new_color):
204228
self._boundingbox[3] + self._padding_top + self._padding_bottom > 0
205229
)
206230
):
207-
if (
208-
len(self.local_group) > 0
209-
): # This can be simplified in CP v6.0, when group.append(0) bug is corrected
231+
# This can be simplified in CP v6.0, when group.append(0) bug is corrected
232+
if len(self.local_group) > 0:
210233
self.local_group.insert(
211234
0, self._create_background_box(lines, y_offset)
212235
)

0 commit comments

Comments
 (0)