Skip to content

Commit 24dd18e

Browse files
authored
Update for box around text
Updated code to allow for background_color to be set for box around text in business card or custom. None = Transparent, Color number Hex = background box color.
1 parent 672ce3d commit 24dd18e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

adafruit_pybadger/pybadger_base.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ def _create_label_group(
355355
font,
356356
scale,
357357
height_adjustment,
358+
background_color=None,
358359
color=0xFFFFFF,
359360
width_adjustment=2,
360361
line_spacing=0.75,
@@ -365,7 +366,7 @@ def _create_label_group(
365366
font = load_font(font, text)
366367

367368
create_label_group = displayio.Group(scale=scale)
368-
create_label = self._label.Label(font, text=text, line_spacing=line_spacing)
369+
create_label = self._label.Label(font, text=text, line_spacing=line_spacing, background_color=background_color)
369370
_, _, width, _ = create_label.bounding_box
370371
create_label.x = (self.display.width // (width_adjustment * scale)) - width // 2
371372
create_label.y = int(self.display.height * (height_adjustment / scale))
@@ -447,6 +448,7 @@ def show_business_card(
447448
name_string=None,
448449
name_scale=1,
449450
name_font=terminalio.FONT,
451+
background_color=None,
450452
email_string_one=None,
451453
email_scale_one=1,
452454
email_font_one=terminalio.FONT,
@@ -491,6 +493,7 @@ def show_business_card(
491493
font=name_font,
492494
scale=name_scale,
493495
height_adjustment=0.73,
496+
background_color=background_color,
494497
)
495498
business_card_label_groups.append(name_group)
496499
if email_string_one:
@@ -499,6 +502,7 @@ def show_business_card(
499502
font=email_font_one,
500503
scale=email_scale_one,
501504
height_adjustment=0.84,
505+
background_color=background_color,
502506
)
503507
business_card_label_groups.append(email_one_group)
504508
if email_string_two:
@@ -507,6 +511,7 @@ def show_business_card(
507511
font=email_font_two,
508512
scale=email_scale_two,
509513
height_adjustment=0.91,
514+
background_color=background_color,
510515
)
511516
business_card_label_groups.append(email_two_group)
512517

0 commit comments

Comments
 (0)