Skip to content

Commit 51fd400

Browse files
committed
Basic stub.
1 parent c6822c7 commit 51fd400

File tree

1 file changed

+238
-4
lines changed

1 file changed

+238
-4
lines changed

buildconfig/stubs/pygame/event.pyi

Lines changed: 238 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,256 @@ from typing import (
44
List,
55
Optional,
66
Union,
7-
final,
7+
Literal,
8+
overload,
9+
Type,
810
)
911

1012
from ._common import Sequence
1113

12-
@final
13-
class Event:
14+
class _EventMeta(type): ...
15+
16+
class Event(metaclass=_EventMeta):
1417
type: int
1518
dict: Dict[str, Any]
1619
__dict__: Dict[str, Any]
1720
__hash__: None # type: ignore
21+
@overload
22+
def __init__(
23+
self, type: int, dict: Dict[str, Any] = ..., /, **kwargs: Any
24+
) -> None: ...
25+
@overload
1826
def __init__(
19-
self, type: int, dict: Dict[str, Any] = ..., **kwargs: Any
27+
self, type: int, dict: Dict[str, Any] = ..., /, **kwargs: Any
2028
) -> None: ...
2129
def __getattribute__(self, name: str) -> Any: ...
2230
def __setattr__(self, name: str, value: Any) -> None: ...
2331
def __delattr__(self, name: str) -> None: ...
2432
def __bool__(self) -> bool: ...
2533

34+
# TODO: fill with arguments.
35+
36+
class ActiveEvent(Event):
37+
type: Literal[32768] = 32768
38+
39+
class AppTerminating(Event):
40+
type: Literal[257] = 257
41+
42+
class AppLowMemory(Event):
43+
type: Literal[258] = 258
44+
45+
class AppWillEnterBackground(Event):
46+
type: Literal[259] = 259
47+
48+
class AppDidEnterBackground(Event):
49+
type: Literal[260] = 260
50+
51+
class AppWillEnterForeground(Event):
52+
type: Literal[261] = 261
53+
54+
class AppDidEnterForeground(Event):
55+
type: Literal[262] = 262
56+
57+
class ClipboardUpdate(Event):
58+
type: Literal[2304] = 2304
59+
60+
class KeyDown(Event):
61+
type: Literal[768] = 768
62+
63+
class KeyUp(Event):
64+
type: Literal[769] = 769
65+
66+
class KeyMapChanged(Event):
67+
type: Literal[772] = 772
68+
69+
class LocaleChanged(Event):
70+
"""Only for SDL 2.0.14+"""
71+
type: Literal[263] = 263
72+
73+
class MouseMotion(Event):
74+
type: Literal[1024] = 1024
75+
76+
class MouseButtonDown(Event):
77+
type: Literal[1025] = 1025
78+
79+
class MouseButtonUp(Event):
80+
type: Literal[1026] = 1026
81+
82+
class JoyAxisMotion(Event):
83+
type: Literal[1536] = 1536
84+
85+
class JoyBallMotion(Event):
86+
type: Literal[1537] = 1537
87+
88+
class JoyHatMotion(Event):
89+
type: Literal[1538] = 1538
90+
91+
class JoyButtonUp(Event):
92+
type: Literal[1540] = 1540
93+
94+
class JoyButtonDown(Event):
95+
type: Literal[1539] = 1539
96+
97+
class Quit(Event):
98+
type: Literal[256] = 256
99+
100+
class SysWMEvent(Event):
101+
type: Literal[513] = 513
102+
103+
class VideoResize(Event):
104+
type: Literal[32769] = 32769
105+
106+
class VideoExpose(Event):
107+
type: Literal[32770] = 32770
108+
109+
class MidiIn(Event):
110+
type: Literal[32771] = 32771
111+
112+
class MidiOut(Event):
113+
type: Literal[32772] = 32772
114+
115+
class NoEvent(Event):
116+
type: Literal[0] = 0
117+
118+
class FingerMotion(Event):
119+
type: Literal[1794] = 1794
120+
121+
class FingerDown(Event):
122+
type: Literal[1792] = 1792
123+
124+
class FingerUp(Event):
125+
type: Literal[1793] = 1793
126+
127+
class MultiGesture(Event):
128+
type: Literal[2050] = 2050
129+
130+
class MouseWheel(Event):
131+
type: Literal[1027] = 1027
132+
133+
class TextInput(Event):
134+
type: Literal[771] = 771
135+
136+
class TextEditing(Event):
137+
type: Literal[770] = 770
138+
139+
class DropFile(Event):
140+
type: Literal[4096] = 4096
141+
142+
class DropText(Event):
143+
type: Literal[4097] = 4097
144+
145+
class DropBegin(Event):
146+
type: Literal[4098] = 4098
147+
148+
class DropComplete(Event):
149+
type: Literal[4099] = 4099
150+
151+
class ControllerAxisMotion(Event):
152+
type: Literal[1616] = 1616
153+
154+
class ControllerButtonDown(Event):
155+
type: Literal[1617] = 1617
156+
157+
class ControllerButtonUp(Event):
158+
type: Literal[1618] = 1618
159+
160+
class ControllerDeviceAdded(Event):
161+
type: Literal[1619] = 1619
162+
163+
class ControllerDeviceRemoved(Event):
164+
type: Literal[1620] = 1620
165+
166+
class ControllerDeviceMapped(Event):
167+
type: Literal[1621] = 1621
168+
169+
class JoyDeviceAdded(Event):
170+
type: Literal[1541] = 1541
171+
172+
class JoyDeviceRemoved(Event):
173+
type: Literal[1542] = 1542
174+
175+
class ControllerTouchpadDown(Event):
176+
"""Only for SDL 2.0.14+"""
177+
type: Literal[1622] = 1622
178+
179+
class ControllerTouchpadMotion(Event):
180+
"""Only for SDL 2.0.14+"""
181+
type: Literal[1623] = 1623
182+
183+
class ControllerTouchpadUp(Event):
184+
"""Only for SDL 2.0.14+"""
185+
type: Literal[1624] = 1624
186+
187+
class ControllerSensorUpdate(Event):
188+
"""Only for SDL 2.0.14+"""
189+
type: Literal[1625] = 1625
190+
191+
class AudioDeviceAdded(Event):
192+
type: Literal[4352] = 4352
193+
194+
class AudioDeviceRemoved(Event):
195+
type: Literal[4353] = 4353
196+
197+
class RenderTargetsReset(Event):
198+
type: Literal[8192] = 8192
199+
200+
class RenderDeviceReset(Event):
201+
type: Literal[8193] = 8193
202+
203+
class WindowShown(Event):
204+
type: Literal[32774] = 32774
205+
206+
class WindowHidden(Event):
207+
type: Literal[32775] = 32775
208+
209+
class WindowExposed(Event):
210+
type: Literal[32776] = 32776
211+
212+
class WindowMoved(Event):
213+
type: Literal[32777] = 32777
214+
215+
class WindowResized(Event):
216+
type: Literal[32778] = 32778
217+
218+
class WindowSizeChanged(Event):
219+
type: Literal[32779] = 32779
220+
221+
class WindowMinimized(Event):
222+
type: Literal[32780] = 32780
223+
224+
class WindowMaximized(Event):
225+
type: Literal[32781] = 32781
226+
227+
class WindowRestored(Event):
228+
type: Literal[32782] = 32782
229+
230+
class WindowEnter(Event):
231+
type: Literal[32783] = 32783
232+
233+
class WindowLeave(Event):
234+
type: Literal[32784] = 32784
235+
236+
class WindowFocusGained(Event):
237+
type: Literal[32785] = 32785
238+
239+
class WindowFocusLost(Event):
240+
type: Literal[32786] = 32786
241+
242+
class WindowClose(Event):
243+
type: Literal[32787] = 32787
244+
245+
class WindowTakeFocus(Event):
246+
type: Literal[32788] = 32788
247+
248+
class WindowHitTest(Event):
249+
type: Literal[32789] = 32789
250+
251+
class WindowICCProfChanged(Event):
252+
type: Literal[32790] = 32790
253+
254+
class WindowDisplayChanged(Event):
255+
type: Literal[32791] = 32791
256+
26257
_EventTypes = Union[int, Sequence[int]]
27258

28259
def pump() -> None: ...
@@ -43,5 +274,8 @@ def set_grab(grab: bool, /) -> None: ...
43274
def get_grab() -> bool: ...
44275
def post(event: Event, /) -> bool: ...
45276
def custom_type() -> int: ...
277+
def event_class(type: int, /) -> Type[Event]: ...
278+
def __dir__() -> List[str]: ...
279+
def __getattr__(name: str, /) -> object: ...
46280

47281
EventType = Event

0 commit comments

Comments
 (0)