Skip to content

Commit d344854

Browse files
committed
Merge branch 'refs/heads/main' into add-annotations
# Conflicts: # adafruit_button/button.py # adafruit_button/button_base.py # adafruit_button/sprite_button.py
2 parents fd29d0f + c368494 commit d344854

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

adafruit_button/button.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
try:
3131
from typing import Optional, Union, Tuple, Any, List
3232
from fontio import FontProtocol
33+
from displayio import Group
3334
except ImportError:
3435
pass
3536

@@ -189,7 +190,7 @@ def __init__(
189190

190191
self.label = label
191192

192-
def _subclass_selected_behavior(self, value: Optional[Any]) -> None:
193+
def _subclass_selected_behavior(self, value: bool) -> None:
193194
if self._selected:
194195
new_fill = self.selected_fill
195196
new_out = self.selected_outline
@@ -202,7 +203,7 @@ def _subclass_selected_behavior(self, value: Optional[Any]) -> None:
202203
self.body.outline = new_out
203204

204205
@property
205-
def group(self) -> "Button":
206+
def group(self) -> Group:
206207
"""Return self for compatibility with old API."""
207208
print(
208209
"Warning: The group property is being deprecated. "
@@ -211,7 +212,7 @@ def group(self) -> "Button":
211212
)
212213
return self
213214

214-
def contains(self, point: List[int]) -> bool:
215+
def contains(self, point: tuple[int, int]) -> bool:
215216
"""Used to determine if a point is contained within a button. For example,
216217
``button.contains(touch)`` where ``touch`` is the touch point on the screen will allow for
217218
determining that a button has been touched.

adafruit_button/button_base.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@
2626
import terminalio
2727

2828
try:
29-
from typing import Optional, Union, Tuple, Any
29+
from typing import Optional, Union, Tuple
3030
from fontio import FontProtocol
3131
except ImportError:
3232
pass
3333

3434

35+
3536
def _check_color(color: Optional[Union[int, tuple[int, int, int]]]) -> int:
3637
# if a tuple is supplied, convert it to a RGB number
3738
if isinstance(color, tuple):
@@ -128,7 +129,7 @@ def label(self, newtext: str) -> None:
128129
if (self.selected_label is None) and (self._label_color is not None):
129130
self.selected_label = (~_check_color(self._label_color)) & 0xFFFFFF
130131

131-
def _subclass_selected_behavior(self, value: Optional[Any]) -> None:
132+
def _subclass_selected_behavior(self, value: bool):
132133
# Subclasses should override this!
133134
pass
134135

adafruit_button/sprite_button.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from adafruit_button.button_base import ButtonBase
2727

2828
try:
29-
from typing import Optional, Union, Tuple, Any, List
29+
from typing import Optional, Union, Tuple, List
3030
from fontio import FontProtocol
3131
except ImportError:
3232
pass
@@ -127,7 +127,7 @@ def height(self) -> int:
127127
"""The height of the button. Read-Only"""
128128
return self._height
129129

130-
def contains(self, point: List[int]) -> bool:
130+
def contains(self, point: Tuple[int, int]) -> bool:
131131
"""Used to determine if a point is contained within a button. For example,
132132
``button.contains(touch)`` where ``touch`` is the touch point on the screen will allow for
133133
determining that a button has been touched.
@@ -136,7 +136,7 @@ def contains(self, point: List[int]) -> bool:
136136
self.y <= point[1] <= self.y + self.height
137137
)
138138

139-
def _subclass_selected_behavior(self, value: Optional[Any]) -> None:
139+
def _subclass_selected_behavior(self, value: bool) -> None:
140140
if self._selected:
141141
if self._selected_bmp is not None:
142142
self._btn_tilegrid.bitmap = self._selected_bmp

0 commit comments

Comments
 (0)