Skip to content

Commit 3f1434d

Browse files
committed
Formatting for sprite_button
Resolving ruff errors for sprite_button.py, some minor formatting elsewhere.
1 parent 2dd2d8b commit 3f1434d

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed

adafruit_button/button.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,23 @@ class Button(ButtonBase):
5353
:param style: The style of the button. Can be RECT, ROUNDRECT, SHADOWRECT, SHADOWROUNDRECT.
5454
Defaults to RECT.
5555
:param Optional[Union[int, Tuple[int, int, int]]] fill_color: The color to fill the button.
56-
Accepts an int or a tuple of 3 integers representing RGB values. Defaults to 0xFFFFFF.
57-
:param Optional[Union[int, Tuple[int, int, int]]] outline_color: The color of the outline of the
58-
button. Accepts an int or a tuple of 3 integers representing RGB values. Defaults to 0x0.
56+
Accepts an int or a tuple of 3 integers representing RGB values. Defaults to 0xFFFFFF.
57+
:param Optional[Union[int, Tuple[int, int, int]]] outline_color: The color of the outline of
58+
the button. Accepts an int or a tuple of 3 integers representing RGB values. Defaults to 0x0.
5959
:param Optional[str] label: The text that appears inside the button.
60-
:param Optional[FontProtocol] label_font: The button label font. Defaults to ''terminalio.FONT''
60+
:param Optional[FontProtocol] label_font: The button label font. Defaults to
61+
''terminalio.FONT''
6162
:param Optional[Union[int, Tuple[int, int, int]]] label_color: The color of the button label
62-
text. Accepts an int or a tuple of 3 integers representing RGB values. Defaults to 0x0.
63+
text. Accepts an int or a tuple of 3 integers representing RGB values. Defaults to 0x0.
6364
:param Optional[Union[int, Tuple[int, int, int]]] selected_fill: The fill color when the
64-
button is selected. Accepts an int or a tuple of 3 integers representing RGB values.
65-
Defaults to the inverse of the fill_color.
65+
button is selected. Accepts an int or a tuple of 3 integers representing RGB values.
66+
Defaults to the inverse of the fill_color.
6667
:param Optional[Union[int, Tuple[int, int, int]]] selected_outline: The outline color when the
6768
button is selected. Accepts an int or a tuple of 3 integers representing RGB values.
6869
Defaults to the inverse of outline_color.
6970
:param Optional[Union[int, Tuple[int, int, int]]] selected_label: The label color when the
70-
button is selected. Accepts an int or a tuple of 3 integers representing RGB values.
71-
Defaults to inverting the label_color.
71+
button is selected. Accepts an int or a tuple of 3 integers representing RGB values.
72+
Defaults to inverting the label_color.
7273
:param Optional[int] label_scale: The scale factor used for the label. Defaults to 1.
7374
"""
7475

adafruit_button/sprite_button.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
pass
3333

3434
class SpriteButton(ButtonBase):
35-
"""Helper class for creating 3x3 Bitmap Spritesheet UI buttons for ``displayio``. Compatible with any format
36-
supported by ''adafruit_imageload''.
35+
"""Helper class for creating 3x3 Bitmap Spritesheet UI buttons for ``displayio``.
36+
Compatible with any format supported by ''adafruit_imageload''.
3737
3838
:param int x: The x position of the button.
3939
:param int y: The y position of the button.
@@ -42,15 +42,16 @@ class SpriteButton(ButtonBase):
4242
:param Optional[str] name: A name, or miscellaneous string that is stored on the button.
4343
:param Optional[str] label: The text that appears inside the button.
4444
:param Optional[FontProtocol] label_font: The button label font.
45-
:param Optional[Union[int, Tuple[int, int, int]]] label_color: The color of the button label text. Accepts either
46-
an integer or a tuple of 3 integers representing RGB values. Defaults to 0x0.
47-
:param Optional[Union[int, Tuple[int, int, int]]] selected_label: The color of the button label text when the button
48-
is selected. Accepts either an integer or a tuple of 3 integers representing RGB values. Defaults to the inverse of
49-
label_color.
45+
:param Optional[Union[int, Tuple[int, int, int]]] label_color: The color of the label text.
46+
Accepts either an integer or a tuple of 3 integers representing RGB values. Defaults to 0x0.
47+
:param Optional[Union[int, Tuple[int, int, int]]] selected_label: The color of the button label
48+
text when the button is selected. Accepts either an integer or a tuple of 3 integers
49+
representing RGB values. Defaults to the inverse of label_color.
5050
:param str bmp_path: The path of the 3x3 spritesheet mage file
51-
:param Optional[str] selected_bmp_path: The path of the 3x3 spritesheet image file to use when pressed
52-
:param Optional[Union[int, Tuple]] transparent_index: Palette index(s) that will be set to transparent. PNG files have these index(s)
53-
set automatically. Not compatible with JPG files.
51+
:param Optional[str] selected_bmp_path: The path of the 3x3 spritesheet image file to use when
52+
pressed
53+
:param Optional[Union[int, Tuple]] transparent_index: Palette index(s) that will be set to
54+
transparent. PNG files have these index(s) set automatically. Not compatible with JPG files.
5455
:param Optional[int] label_scale: The scale multiplier of the button label. Defaults to 1.
5556
"""
5657

@@ -64,11 +65,11 @@ def __init__(
6465
name: Optional[str] = None,
6566
label: Optional[str] = None,
6667
label_font: Optional[FontProtocol] = None,
67-
label_color: Optional[Union[int, tuple[int, int, int]]] = 0x0,
68-
selected_label: Optional[Union[int, tuple[int, int, int]]] = None,
68+
label_color: Optional[Union[int, Tuple[int, int, int]]] = 0x0,
69+
selected_label: Optional[Union[int, Tuple[int, int, int]]] = None,
6970
bmp_path: str = None,
7071
selected_bmp_path: Optional[str] = None,
71-
transparent_index: Optional[Union[int, tuple]] = None,
72+
transparent_index: Optional[Union[int, Tuple]] = None,
7273
label_scale: Optional[int] = 1
7374
):
7475
if bmp_path is None:
@@ -125,7 +126,7 @@ def height(self) -> int:
125126
"""The height of the button. Read-Only"""
126127
return self._height
127128

128-
def contains(self, point: list[int]) -> bool:
129+
def contains(self, point: List[int]) -> bool:
129130
"""Used to determine if a point is contained within a button. For example,
130131
``button.contains(touch)`` where ``touch`` is the touch point on the screen will allow for
131132
determining that a button has been touched.

0 commit comments

Comments
 (0)