diff --git a/adafruit_display_text/__init__.py b/adafruit_display_text/__init__.py index acdb2e5..c0ce501 100644 --- a/adafruit_display_text/__init__.py +++ b/adafruit_display_text/__init__.py @@ -279,15 +279,13 @@ def background_color(self): """Color of the background as an RGB hex number.""" return self._background_color + def _set_background_color(self, new_color): + # subclasses should override this + pass + @background_color.setter def background_color(self, new_color): - self._background_color = new_color - if new_color is not None: - self.palette[0] = new_color - self.palette.make_opaque(0) - else: - self.palette[0] = 0 - self.palette.make_transparent(0) + self._set_background_color(new_color) @property def anchor_point(self): diff --git a/adafruit_display_text/bitmap_label.py b/adafruit_display_text/bitmap_label.py index 027a691..9d9f072 100755 --- a/adafruit_display_text/bitmap_label.py +++ b/adafruit_display_text/bitmap_label.py @@ -554,3 +554,12 @@ def _set_font(self, new_font): def _set_text(self, new_text, scale): new_text = self._tab_text.join(new_text.split("\t")) self._reset_text(text=new_text, scale=self.scale) + + def _set_background_color(self, new_color): + self._background_color = new_color + if new_color is not None: + self.palette[0] = new_color + self.palette.make_opaque(0) + else: + self.palette[0] = 0 + self.palette.make_transparent(0) diff --git a/adafruit_display_text/label.py b/adafruit_display_text/label.py index b93b969..dadc7f0 100755 --- a/adafruit_display_text/label.py +++ b/adafruit_display_text/label.py @@ -329,3 +329,6 @@ def _set_line_spacing(self, new_line_spacing): def _set_text(self, new_text, scale): self._reset_text(new_text) + + def _set_background_color(self, new_color): + self._update_background_color(new_color)