Skip to content

Commit ae6ced5

Browse files
committed
Updated label_color for compatibility
label_color now accepts a tuple as well as an int for color, bringing its behavior in line with selected_label
1 parent 11a570c commit ae6ced5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

adafruit_button/button_base.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ class ButtonBase(Group):
5050
:param Optional[str] name: A name, or miscellaneous string that is stored on the button.
5151
:param Optional[str] label: The text that appears inside the button.
5252
:param Optional[FontProtocol] label_font: The button label font. Defaults to ''terminalio.FONT''
53-
:param Optional[int] label_color: The color of the button label text. Defaults to 0x0.
53+
:param Optional[Union[int, Tuple[int, int, int]]] label_color: The color of the button label text. Defaults to 0x0.
54+
Accepts an int or a tuple of 3 integers representing RGB values. Defaults to an inverse of label_color.
5455
:param Optional[Union[int, Tuple[int, int, int]]] selected_label: The color of button label text when the button is selected.
5556
Accepts an int or a tuple of 3 integers representing RGB values. Defaults to an inverse of label_color.
5657
:param Optional[int] label_scale: The scale factor used for the label. Defaults to 1.
@@ -66,7 +67,7 @@ def __init__(
6667
name: Optional[str] = None,
6768
label: Optional[str] = None,
6869
label_font: Optional[FontProtocol] = None,
69-
label_color: Optional[int] = 0x0,
70+
label_color: Optional[Union[int, tuple[int, int, int]]] = 0x0,
7071
selected_label: Optional[Union[int, tuple[int, int, int]]] = None,
7172
label_scale: Optional[int] = 1,
7273
) -> None:
@@ -79,7 +80,7 @@ def __init__(
7980
self._selected = False
8081
self.name = name
8182
self._label = label
82-
self._label_color = label_color
83+
self._label_color = _check_color(label_color)
8384
self._label_font = label_font
8485
self._selected_label = _check_color(selected_label)
8586
self._label_scale = label_scale

0 commit comments

Comments
 (0)