2020# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2121# THE SOFTWARE.
2222
23+ """
24+ `adafruit_display_notification`
25+ ================================================================================
26+
27+ Very basic notification widgets.
28+
29+ """
30+
2331import displayio
2432
25- from adafruit_bitmap_font import bitmap_font
2633from adafruit_display_text import label
2734
2835import terminalio
2936
3037__version__ = "0.0.0-auto.0"
3138__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Display_Notification.git"
3239
33- #text_font = bitmap_font.load_font("/Helvetica-Bold-16.bdf")
34- text_font = terminalio .FONT
40+ TEXT_FONT = terminalio .FONT
41+
42+ # pylint: disable=too-few-public-methods
3543
3644class NotificationFree (displayio .Group ):
45+ """Widget to show when no notifications are active."""
3746 def __init__ (self , width , height , * , dark_mode = True ):
47+ # pylint: disable=unused-argument
3848 super ().__init__ ()
3949
4050 if dark_mode :
@@ -43,35 +53,39 @@ def __init__(self, width, height, *, dark_mode=True):
4353 text_color = 0x000000
4454
4555 # Create the text label
46- self .title = label .Label (text_font , text = "None!" , y = height // 2 , color = text_color )
56+ self .title = label .Label (TEXT_FONT , text = "None!" , y = height // 2 , color = text_color )
4757 self .append (self .title )
4858
4959class PlainNotification (displayio .Group ):
60+ """Plain text widget with a title and message."""
5061 def __init__ (self , title , message , width , height , * , dark_mode = True ):
5162 super ().__init__ ()
5263
53- #Create group holding text
54- text_group = displayio .Group (max_size = 10 , scale = 1 )
5564 # Set text, font, and color
5665 if dark_mode :
5766 text_color = 0xffffff
5867 else :
5968 text_color = 0x000000
6069
6170 # Create the text label
62- self .title = label .Label (text_font , text = title , color = text_color , y = 8 )
71+ self .title = label .Label (TEXT_FONT , text = title , color = text_color , y = 8 )
6372 self .append (self .title )
6473
6574 # TODO: Move this into Label or a TextBox.
66- lines = self ._wrap_nicely (message , width // 7 )
75+ lines = PlainNotification ._wrap_nicely (message , width // 7 )
6776 max_lines = height // 20
6877 message = "\n " .join (lines [:max_lines ])
6978
70- self .message = label .Label (terminalio .FONT , text = message , color = text_color , x = 2 , y = height // 2 + 8 )
79+ self .message = label .Label (terminalio .FONT ,
80+ text = message ,
81+ color = text_color ,
82+ x = 2 ,
83+ y = height // 2 + 8 )
7184 self .append (self .message )
7285
7386 # cribbed from pyportal
74- def _wrap_nicely (self , string , max_chars ):
87+ @staticmethod
88+ def _wrap_nicely (string , max_chars ):
7589 """A helper that will return a list of lines with word-break wrapping.
7690 :param str string: The text to be wrapped.
7791 :param int max_chars: The maximum number of characters on a line before wrapping.
0 commit comments