Skip to content

Commit

Permalink
Merge pull request #188 from FoamyGuy/scrolling_label_text_prop
Browse files Browse the repository at this point in the history
override text property from parent on ScrollingLabel
  • Loading branch information
jposada202020 authored Mar 13, 2023
2 parents 81998a6 + 4436be5 commit 635ad4e
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions adafruit_display_text/scrolling_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def update(self, force: bool = False) -> None:
if force or self._last_animate_time + self.animate_time <= _now:

if len(self.full_text) <= self.max_characters:
self.text = self.full_text
super()._set_text(self.full_text, self.scale)
self._last_animate_time = _now
return

Expand All @@ -106,8 +106,7 @@ def update(self, force: bool = False) -> None:
_showing_string = "{}{}".format(
_showing_string_start, _showing_string_end
)
self.text = _showing_string

super()._set_text(_showing_string, self.scale)
self.current_index += 1
self._last_animate_time = _now

Expand Down Expand Up @@ -144,3 +143,16 @@ def full_text(self, new_text: str) -> None:
self._full_text = new_text
self.current_index = 0
self.update()

@property
def text(self):
"""The full text to be shown. If it's longer than ``max_characters`` then
scrolling will occur as needed.
:return str: The full text of this label.
"""
return self.full_text

@text.setter
def text(self, new_text):
self.full_text = new_text

0 comments on commit 635ad4e

Please sign in to comment.