|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | | -from typing import Iterable |
| 3 | +from typing import Iterable, TypeVar |
4 | 4 |
|
5 | 5 | from pyglet.event import EVENT_UNHANDLED |
6 | 6 |
|
|
23 | 23 | ) |
24 | 24 | from arcade.types import LBWH |
25 | 25 |
|
| 26 | +W = TypeVar("W", bound="UIWidget") |
| 27 | + |
26 | 28 |
|
27 | 29 | class UIScrollBar(UIWidget): |
28 | 30 | """Scroll bar for a UIScrollLayout. |
@@ -210,7 +212,7 @@ def __init__( |
210 | 212 | y: float = 0, |
211 | 213 | width: float = 300, |
212 | 214 | height: float = 300, |
213 | | - children: Iterable["UIWidget"] = tuple(), |
| 215 | + children: Iterable[UIWidget] = tuple(), |
214 | 216 | size_hint=None, |
215 | 217 | size_hint_min=None, |
216 | 218 | size_hint_max=None, |
@@ -242,15 +244,17 @@ def __init__( |
242 | 244 | bind(self, "scroll_x", self.trigger_full_render) |
243 | 245 | bind(self, "scroll_y", self.trigger_full_render) |
244 | 246 |
|
245 | | - def add(self, child: "UIWidget", **kwargs): |
| 247 | + def add(self, child: W, **kwargs) -> W: |
246 | 248 | """Add a child to the widget.""" |
247 | 249 | if self._children: |
248 | 250 | raise ValueError("UIScrollArea can only have one child") |
249 | 251 |
|
250 | 252 | super().add(child, **kwargs) |
251 | 253 | self.trigger_full_render() |
252 | 254 |
|
253 | | - def remove(self, child: "UIWidget"): |
| 255 | + return child |
| 256 | + |
| 257 | + def remove(self, child: UIWidget): |
254 | 258 | """Remove a child from the widget.""" |
255 | 259 | super().remove(child) |
256 | 260 | self.trigger_full_render() |
|
0 commit comments