Skip to content

Commit 8de4f5c

Browse files
authored
Merge pull request #109 from kmatch98/fix_anchor_point
Fix anchor point, anchored_position and scale
2 parents 9b7fc23 + 1dfe695 commit 8de4f5c

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

adafruit_display_text/bitmap_label.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,24 @@ class Label(displayio.Group):
4949
Must include a capital M for measuring character size.
5050
:param str text: Text to display
5151
:param int max_glyphs: Unnecessary parameter (provided only for direct compability
52-
with label.py)
52+
with label.py)
5353
:param int color: Color of all text in RGB hex
5454
:param int background_color: Color of the background, use `None` for transparent
5555
:param double line_spacing: Line spacing of text to display
5656
:param boolean background_tight: Set `True` only if you want background box to tightly
57-
surround text
57+
surround text
5858
:param int padding_top: Additional pixels added to background bounding box at top
5959
:param int padding_bottom: Additional pixels added to background bounding box at bottom
6060
:param int padding_left: Additional pixels added to background bounding box at left
6161
:param int padding_right: Additional pixels added to background bounding box at right
6262
:param (double,double) anchor_point: Point that anchored_position moves relative to.
63-
Tuple with decimal percentage of width and height.
64-
(E.g. (0,0) is top left, (1.0, 0.5): is middle right.)
63+
Tuple with decimal percentage of width and height.
64+
(E.g. (0,0) is top left, (1.0, 0.5): is middle right.)
6565
:param (int,int) anchored_position: Position relative to the anchor_point. Tuple
66-
containing x,y pixel coordinates.
66+
containing x,y pixel coordinates.
6767
:param int scale: Integer value of the pixel scaling
6868
:param bool save_text: Set True to save the text string as a constant in the
69-
label structure. Set False to reduce memory use.
70-
"""
69+
label structure. Set False to reduce memory use."""
7170

7271
# pylint: disable=unused-argument, too-many-instance-attributes, too-many-locals, too-many-arguments
7372
# pylint: disable=too-many-branches, no-self-use, too-many-statements
@@ -185,15 +184,11 @@ def _reset_text(
185184
if padding_right is not None:
186185
self._padding_right = max(0, padding_right)
187186
if anchor_point is not None:
188-
self.anchor_point = anchor_point
187+
self._anchor_point = anchor_point
189188
if anchored_position is not None:
190189
self._anchored_position = anchored_position
191190
if save_text is not None:
192191
self._save_text = save_text
193-
if (
194-
scale is not None
195-
): # Scale will be defined in local_group (Note: self should have scale=1)
196-
self.scale = scale # call the setter
197192

198193
# if text is not provided as a parameter (text is None), use the previous value.
199194
if (text is None) and self._save_text:
@@ -298,6 +293,11 @@ def _reset_text(
298293
tight_box_y,
299294
)
300295

296+
if (
297+
scale is not None
298+
): # Scale will be defined in local_group (Note: self should have scale=1)
299+
self.scale = scale # call the setter
300+
301301
self.anchored_position = (
302302
self._anchored_position
303303
) # set the anchored_position with setter after bitmap is created, sets the

0 commit comments

Comments
 (0)