Skip to content

Commit fb5efb1

Browse files
committed
Ran black
1 parent 30d001e commit fb5efb1

File tree

1 file changed

+48
-46
lines changed

1 file changed

+48
-46
lines changed

adafruit_display_text/bitmap_label.py

Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -48,43 +48,43 @@
4848

4949
class Label(displayio.Group):
5050
"""A label displaying a string of text that is stored in a bitmap.
51-
Note: This ``bitmap_label.py`` library utilizes a bitmap to display the text.
52-
This method is memory-conserving relative to ``label.py``.
53-
The ``max_glyphs`` parameter is ignored and is present
54-
only for direct compatability with label.py.
55-
56-
For further reduction in memory usage, set ``save_text=False`` (text string will not
57-
be stored and ``line_spacing`` and ``font`` are immutable with ``save_text``
58-
set to ``False``).
59-
60-
The origin point set by ``x`` and ``y``
61-
properties will be the left edge of the bounding box, and in the center of a M
62-
glyph (if its one line), or the (number of lines * linespacing + M)/2. That is,
63-
it will try to have it be center-left as close as possible.
64-
65-
:param Font font: A font class that has ``get_bounding_box`` and ``get_glyph``.
66-
Must include a capital M for measuring character size.
67-
:param str text: Text to display
68-
:param int max_glyphs: Unnecessary parameter (provided only for direct compability
69-
with label.py)
70-
:param int color: Color of all text in RGB hex
71-
:param int background_color: Color of the background, use `None` for transparent
72-
:param double line_spacing: Line spacing of text to display
73-
:param boolean background_tight: Set `True` only if you want background box to tightly
74-
surround text
75-
:param int padding_top: Additional pixels added to background bounding box at top
76-
:param int padding_bottom: Additional pixels added to background bounding box at bottom
77-
:param int padding_left: Additional pixels added to background bounding box at left
78-
:param int padding_right: Additional pixels added to background bounding box at right
79-
:param (double,double) anchor_point: Point that anchored_position moves relative to.
80-
Tuple with decimal percentage of width and height.
81-
(E.g. (0,0) is top left, (1.0, 0.5): is middle right.)
82-
:param (int,int) anchored_position: Position relative to the anchor_point. Tuple
83-
containing x,y pixel coordinates.
84-
:param int scale: Integer value of the pixel scaling
85-
:param bool save_text: Set True to save the text string as a constant in the
86-
label structure. Set False to reduce memory use.
87-
"""
51+
Note: This ``bitmap_label.py`` library utilizes a bitmap to display the text.
52+
This method is memory-conserving relative to ``label.py``.
53+
The ``max_glyphs`` parameter is ignored and is present
54+
only for direct compatability with label.py.
55+
56+
For further reduction in memory usage, set ``save_text=False`` (text string will not
57+
be stored and ``line_spacing`` and ``font`` are immutable with ``save_text``
58+
set to ``False``).
59+
60+
The origin point set by ``x`` and ``y``
61+
properties will be the left edge of the bounding box, and in the center of a M
62+
glyph (if its one line), or the (number of lines * linespacing + M)/2. That is,
63+
it will try to have it be center-left as close as possible.
64+
65+
:param Font font: A font class that has ``get_bounding_box`` and ``get_glyph``.
66+
Must include a capital M for measuring character size.
67+
:param str text: Text to display
68+
:param int max_glyphs: Unnecessary parameter (provided only for direct compability
69+
with label.py)
70+
:param int color: Color of all text in RGB hex
71+
:param int background_color: Color of the background, use `None` for transparent
72+
:param double line_spacing: Line spacing of text to display
73+
:param boolean background_tight: Set `True` only if you want background box to tightly
74+
surround text
75+
:param int padding_top: Additional pixels added to background bounding box at top
76+
:param int padding_bottom: Additional pixels added to background bounding box at bottom
77+
:param int padding_left: Additional pixels added to background bounding box at left
78+
:param int padding_right: Additional pixels added to background bounding box at right
79+
:param (double,double) anchor_point: Point that anchored_position moves relative to.
80+
Tuple with decimal percentage of width and height.
81+
(E.g. (0,0) is top left, (1.0, 0.5): is middle right.)
82+
:param (int,int) anchored_position: Position relative to the anchor_point. Tuple
83+
containing x,y pixel coordinates.
84+
:param int scale: Integer value of the pixel scaling
85+
:param bool save_text: Set True to save the text string as a constant in the
86+
label structure. Set False to reduce memory use.
87+
"""
8888

8989
# pylint: disable=unused-argument, too-many-instance-attributes, too-many-locals, too-many-arguments
9090
# pylint: disable=too-many-branches, no-self-use, too-many-statements
@@ -118,7 +118,11 @@ def __init__(
118118
# self Group will contain a single local_group which contains a Group (self.local_group)
119119
# which contains a TileGrid (self.tilegrid) which contains the text bitmap (self.bitmap)
120120
super().__init__(
121-
max_size=1, x=x, y=y, scale=1, **kwargs,
121+
max_size=1,
122+
x=x,
123+
y=y,
124+
scale=1,
125+
**kwargs,
122126
)
123127
# the self group scale should always remain at 1, the self.local_group will
124128
# be used to set the scale
@@ -204,7 +208,6 @@ def _reset_text(
204208
if save_text is not None:
205209
self._save_text = save_text
206210

207-
208211
# if text is not provided as a parameter (text is None), use the previous value.
209212
if (text is None) and self._save_text:
210213
text = self._text
@@ -244,7 +247,9 @@ def _reset_text(
244247
loose_box_y,
245248
loose_y_offset,
246249
) = self._text_bounding_box(
247-
text, self._font, self._line_spacing,
250+
text,
251+
self._font,
252+
self._line_spacing,
248253
) # calculate the box size for a tight and loose backgrounds
249254

250255
if self._background_tight:
@@ -305,7 +310,6 @@ def _reset_text(
305310
tight_box_y,
306311
)
307312

308-
309313
if (
310314
scale is not None
311315
): # Scale will be defined in local_group (Note: self should have scale=1)
@@ -316,8 +320,6 @@ def _reset_text(
316320
) # set the anchored_position with setter after bitmap is created, sets the
317321
# x,y positions of the label
318322

319-
320-
321323
@staticmethod
322324
def _line_spacing_ypixels(font, line_spacing):
323325
# Note: Scaling is provided at the Group level
@@ -649,8 +651,8 @@ def font(self, new_font):
649651
@property
650652
def anchor_point(self):
651653
"""Point that anchored_position moves relative to.
652-
Tuple with decimal percentage of width and height.
653-
(E.g. (0,0) is top left, (1.0, 0.5): is middle right.)"""
654+
Tuple with decimal percentage of width and height.
655+
(E.g. (0,0) is top left, (1.0, 0.5): is middle right.)"""
654656
return self._anchor_point
655657

656658
@anchor_point.setter
@@ -663,7 +665,7 @@ def anchor_point(self, new_anchor_point):
663665
@property
664666
def anchored_position(self):
665667
"""Position relative to the anchor_point. Tuple containing x,y
666-
pixel coordinates."""
668+
pixel coordinates."""
667669
return self._anchored_position
668670

669671
@anchored_position.setter

0 commit comments

Comments
 (0)