Skip to content

Commit 7ba8088

Browse files
committed
Merge branch 'adafruit_master' into tab_replacement
# Conflicts: # adafruit_display_text/__init__.py
2 parents 69e3c7c + 5934db7 commit 7ba8088

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

adafruit_display_text/__init__.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"""
66
Display Text module helper functions
77
"""
8-
98
try:
109
from typing import Tuple
1110
except ImportError:
@@ -180,9 +179,9 @@ class LabelBase(Group):
180179
:param int scale: Integer value of the pixel scaling
181180
:param bool save_text: Set True to save the text string as a constant in the
182181
label structure. Set False to reduce memory use.
183-
:param: bool base_alignment: when True allows to align text label to the baseline.
182+
:param bool base_alignment: when True allows to align text label to the baseline.
184183
This is helpful when two or more labels need to be aligned to the same baseline
185-
:param: (int,str) tab_replacement: tuple with tab character replace information. When
184+
:param (int,str) tab_replacement: tuple with tab character replace information. When
186185
(4, " ") will indicate a tab replacement of 4 spaces, defaults to 4 spaces by
187186
tab character"""
188187

@@ -293,15 +292,13 @@ def background_color(self) -> int:
293292
"""Color of the background as an RGB hex number."""
294293
return self._background_color
295294

295+
def _set_background_color(self, new_color):
296+
# subclasses should override this
297+
pass
298+
296299
@background_color.setter
297300
def background_color(self, new_color: int) -> None:
298-
self._background_color = new_color
299-
if new_color is not None:
300-
self.palette[0] = new_color
301-
self.palette.make_opaque(0)
302-
else:
303-
self.palette[0] = 0
304-
self.palette.make_transparent(0)
301+
self._set_background_color(new_color)
305302

306303
@property
307304
def anchor_point(self) -> Tuple[float, float]:

adafruit_display_text/bitmap_label.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,3 +559,12 @@ def _set_font(self, new_font) -> None:
559559
def _set_text(self, new_text: str, scale: int) -> None:
560560
new_text = self._tab_text.join(new_text.split("\t"))
561561
self._reset_text(text=new_text, scale=self.scale)
562+
563+
def _set_background_color(self, new_color):
564+
self._background_color = new_color
565+
if new_color is not None:
566+
self.palette[0] = new_color
567+
self.palette.make_opaque(0)
568+
else:
569+
self.palette[0] = 0
570+
self.palette.make_transparent(0)

adafruit_display_text/label.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,3 +330,6 @@ def _set_line_spacing(self, new_line_spacing: float) -> None:
330330

331331
def _set_text(self, new_text: str, scale: int) -> None:
332332
self._reset_text(new_text)
333+
334+
def _set_background_color(self, new_color):
335+
self._update_background_color(new_color)

0 commit comments

Comments
 (0)