PlayPy 0.2.1__tar.gz → 0.3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. playpy-0.3.1/PKG-INFO +431 -0
  2. playpy-0.3.1/README.md +419 -0
  3. {playpy-0.2.1 → playpy-0.3.1}/pyproject.toml +1 -1
  4. playpy-0.3.1/src/PlayPy.egg-info/PKG-INFO +431 -0
  5. playpy-0.3.1/src/PlayPy.egg-info/SOURCES.txt +20 -0
  6. playpy-0.3.1/src/playpy/__init__.py +492 -0
  7. playpy-0.3.1/src/playpy/builtin/__init__.py +38 -0
  8. playpy-0.3.1/src/playpy/builtin/components.py +82 -0
  9. playpy-0.3.1/src/playpy/builtin/effects.py +345 -0
  10. playpy-0.3.1/src/playpy/builtin/elements.py +546 -0
  11. playpy-0.3.1/src/playpy/builtin/events.py +135 -0
  12. playpy-0.3.1/src/playpy/core/__init__.py +40 -0
  13. playpy-0.3.1/src/playpy/core/elements.py +231 -0
  14. {playpy-0.2.1/src/playpy → playpy-0.3.1/src/playpy/core}/resources.py +26 -15
  15. {playpy-0.2.1/src/playpy → playpy-0.3.1/src/playpy/core}/state.py +234 -72
  16. playpy-0.3.1/src/playpy/core/workspace.py +455 -0
  17. playpy-0.2.1/PKG-INFO +0 -191
  18. playpy-0.2.1/README.md +0 -158
  19. playpy-0.2.1/src/PlayPy.egg-info/PKG-INFO +0 -191
  20. playpy-0.2.1/src/PlayPy.egg-info/SOURCES.txt +0 -15
  21. playpy-0.2.1/src/playpy/__init__.py +0 -222
  22. playpy-0.2.1/src/playpy/builtin.py +0 -638
  23. playpy-0.2.1/src/playpy/elements.py +0 -205
  24. playpy-0.2.1/src/playpy/workspace.py +0 -432
  25. /playpy-0.2.1/LICENSE → /playpy-0.3.1/LICENSE.txt +0 -0
  26. {playpy-0.2.1 → playpy-0.3.1}/setup.cfg +0 -0
  27. {playpy-0.2.1 → playpy-0.3.1}/src/PlayPy.egg-info/dependency_links.txt +0 -0
  28. {playpy-0.2.1 → playpy-0.3.1}/src/PlayPy.egg-info/requires.txt +0 -0
  29. {playpy-0.2.1 → playpy-0.3.1}/src/PlayPy.egg-info/top_level.txt +0 -0
  30. {playpy-0.2.1 → playpy-0.3.1}/src/playpy/data/default_icon.ppm +0 -0
playpy-0.3.1/PKG-INFO ADDED
@@ -0,0 +1,431 @@
1
+ Metadata-Version: 2.4
2
+ Name: PlayPy
3
+ Version: 0.3.1
4
+ Summary: PlayPy is a lightweight Python library for creating simple games and interactive applications with ease. It provides a straightforward API for handling graphics, input, and basic game mechanics, making it ideal for beginners and those looking to quickly prototype their ideas.
5
+ Author-email: angel <angyv2861@gmail.com>
6
+ Requires-Python: >=3.14
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE.txt
9
+ Requires-Dist: pygame-ce>=2.5.6
10
+ Requires-Dist: colorama>=0.4.6
11
+ Dynamic: license-file
12
+
13
+ # PlayPy (0.3.1)
14
+
15
+ PlayPy is a lightweight Python library for creating games, tools, and interactive applications using a retained-mode UI and scene system built on top of pygame. It focuses on rapid prototyping, composable rendering, and simple but powerful layout primitives.
16
+
17
+ ## Requirements
18
+
19
+ - Python `>=3.11`
20
+ - `pygame(-ce) >=2.6.1`
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ pip install playpy
26
+ ```
27
+
28
+ If that does not work:
29
+
30
+ ```bash
31
+ python -m pip install playpy
32
+ ```
33
+
34
+ ---
35
+
36
+ # Core Concepts
37
+
38
+ ## Workspace
39
+
40
+ `Workspace` owns:
41
+ - the window
42
+ - render loop
43
+ - input state
44
+ - scene stack
45
+ - coroutine scheduler
46
+
47
+ Key methods:
48
+
49
+ ```python
50
+ ws.run()
51
+ ws.quit()
52
+
53
+ ws.queue_scene_change(scene)
54
+ ws.queue_scene_push(scene)
55
+ ws.queue_scene_pop(scene=None)
56
+
57
+ ws.step()
58
+ ```
59
+
60
+ ### Scene Scope
61
+
62
+ Temporarily push a scene using a context manager:
63
+
64
+ ```python
65
+ with ws.scene_scope(scene) as (scn, handle):
66
+ ...
67
+ ```
68
+
69
+ Call:
70
+
71
+ ```python
72
+ handle.disconnect()
73
+ ```
74
+
75
+ to remotely pop the scoped scene.
76
+
77
+ ---
78
+
79
+ ## Layout Values
80
+
81
+ PlayPy uses two rectangle value types:
82
+
83
+ ### `FRect`
84
+ Relative scale values.
85
+
86
+ ```python
87
+ plp.FRect(x, y, w, h)
88
+ ```
89
+
90
+ ### `Rect`
91
+ Absolute pixel offsets.
92
+
93
+ ```python
94
+ plp.Rect(x, y, w, h)
95
+ ```
96
+
97
+ Final element rectangle:
98
+
99
+ ```text
100
+ (scale * parent_size) + offset
101
+ ```
102
+
103
+ Helpers:
104
+
105
+ ```python
106
+ plp.empty_rect()
107
+ plp.empty_frect()
108
+ plp.full_screen_rect()
109
+ ```
110
+
111
+ Rect types are iterable and support multiple constructor overloads.
112
+
113
+ ---
114
+
115
+ # Parenting
116
+
117
+ Any `Element` can contain children.
118
+
119
+ ```python
120
+ child.parent = parent
121
+ ```
122
+
123
+ or:
124
+
125
+ ```python
126
+ parent.add_child(child)
127
+ ```
128
+
129
+ Relationship helpers:
130
+
131
+ ```python
132
+ is_parent_of()
133
+ is_child_of()
134
+
135
+ is_ancestor_of()
136
+ is_descendant_of()
137
+ ```
138
+
139
+ Properties:
140
+
141
+ ```python
142
+ parent
143
+ children
144
+ ancestors
145
+ descendants
146
+ ```
147
+
148
+ ---
149
+
150
+ # Rendering System
151
+
152
+ PlayPy now uses a compositing pipeline.
153
+
154
+ `Element.draw()` returns a `SurfaceHandler` instead of drawing directly to the workspace.
155
+
156
+ This enables:
157
+ - outlines for arbitrary shapes
158
+ - gradients inheriting shape alpha
159
+ - subtree compositing
160
+ - layered visual effects
161
+ - future post-processing support
162
+
163
+ ---
164
+
165
+ # Elements
166
+
167
+ ## Core Elements
168
+
169
+ - `Panel`
170
+ - `Text`
171
+ - `Button`
172
+ - `Textbox`
173
+ - `Line`
174
+ - `Scene`
175
+
176
+ ## Effects
177
+
178
+ `Effect` is a subclass of `Element` that visually modifies its parent subtree.
179
+
180
+ Built-in effects:
181
+
182
+ - `Gradient`
183
+ - `ButtonGradient`
184
+ - `Outline`
185
+ - `BorderRadius`
186
+
187
+ Effects are ordered using `z`.
188
+
189
+ Typical layering:
190
+
191
+ ```text
192
+ Negative z:
193
+ backgrounds/gradients
194
+
195
+ Normal z:
196
+ content
197
+
198
+ Positive z:
199
+ outlines/glows/overlays
200
+ ```
201
+
202
+ ## Components
203
+
204
+ `Component`s modify behavior/layout but do not draw.
205
+
206
+ Built-in components:
207
+
208
+ - `Padding`
209
+ - `Font`
210
+ - `Camera`
211
+ - `Scrollable`
212
+ - `GlobalElement`
213
+
214
+ Attach/get/remove:
215
+
216
+ ```python
217
+ element.set_component(component)
218
+
219
+ element.get_component(ComponentType)
220
+
221
+ element.remove_component(ComponentType)
222
+ ```
223
+
224
+ or:
225
+
226
+ ```python
227
+ component.parent = element
228
+ ```
229
+
230
+ ---
231
+
232
+ # Input State
233
+
234
+ Access input using:
235
+
236
+ ```python
237
+ workspace.input
238
+ ```
239
+
240
+ Properties:
241
+
242
+ ```python
243
+ keys_pressed
244
+ key_downs
245
+ key_ups
246
+
247
+ mouse_buttons_pressed
248
+ mouse_downs
249
+ mouse_ups
250
+
251
+ mouse_pos
252
+ mouse_delta
253
+ mouse_wheel
254
+
255
+ text_input
256
+
257
+ dt
258
+ runtime
259
+ quit
260
+ ```
261
+
262
+ Helper methods:
263
+
264
+ ```python
265
+ key_held()
266
+ key_down()
267
+ key_up()
268
+
269
+ mousebutton_held()
270
+ mousebutton_down()
271
+ mousebutton_up()
272
+ ```
273
+
274
+ ---
275
+
276
+ # Hover State
277
+
278
+ Workspace hover helpers:
279
+
280
+ ```python
281
+ is_mouse_top(element)
282
+ is_mouse_over(element)
283
+
284
+ just_hovered(element)
285
+ just_unhovered(element)
286
+
287
+ just_hovered_inclusive(element)
288
+ just_unhovered_inclusive(element)
289
+ ```
290
+
291
+ Event helpers:
292
+
293
+ ```python
294
+ @on_hover(...)
295
+ @on_unhover(...)
296
+ @while_hovered(...)
297
+
298
+ @on_hover_inclusive(...)
299
+ @on_unhover_inclusive(...)
300
+ @while_hovered_inclusive(...)
301
+ ```
302
+
303
+ ---
304
+
305
+ # Events
306
+
307
+ Decorator helpers create `Event` elements.
308
+
309
+ ```python
310
+ @plp.on_start(target)
311
+ @plp.on_update(target)
312
+ @plp.on_quit(target)
313
+
314
+ @plp.on_scene_change(target)
315
+
316
+ @plp.create_event(target, condition)
317
+ ```
318
+
319
+ Events attached to the main workspace are global by default.
320
+
321
+ Example:
322
+
323
+ ```python
324
+ @plp.on_update(ws)
325
+ def tick(w: plp.Workspace):
326
+ if w.input.key_down(plp.Key.ESCAPE):
327
+ w.quit()
328
+ ```
329
+
330
+ ---
331
+
332
+ # Coroutines
333
+
334
+ Event-like functions can yield.
335
+
336
+ If a handler returns a generator, PlayPy resumes it on future frames.
337
+
338
+ Example:
339
+
340
+ ```python
341
+ def flash(_: plp.Workspace):
342
+ for _ in range(60):
343
+ print("frame")
344
+ yield
345
+ ```
346
+
347
+ Supported in:
348
+ - event callbacks
349
+ - button callbacks
350
+ - textbox callbacks
351
+ - other event-like handlers
352
+
353
+ ---
354
+
355
+ # Textbox Features
356
+
357
+ `Textbox` supports:
358
+ - placeholders
359
+ - caret blinking
360
+ - text confirmation/reverting
361
+ - character filtering
362
+ - maximum length
363
+ - coroutine callbacks
364
+
365
+ Useful arguments:
366
+
367
+ ```python
368
+ is_char_accepted=
369
+ on_text_updated=
370
+ confirm_on_click_off=
371
+ ```
372
+
373
+ Special keys:
374
+
375
+ ```text
376
+ Backspace -> remove character
377
+ Delete -> clear text
378
+ Return -> confirm text
379
+ Escape -> revert text
380
+ ```
381
+
382
+ ---
383
+
384
+ # Scenes
385
+
386
+ Scenes support lifecycle hooks:
387
+
388
+ ```python
389
+ on_enter()
390
+ on_exit()
391
+ on_pause()
392
+ on_resume()
393
+ ```
394
+
395
+ Scene changes are queued internally.
396
+
397
+ ---
398
+
399
+ # Cameras and Scrolling
400
+
401
+ `Camera` offsets descendant elements.
402
+
403
+ `Scrollable` extends camera functionality with built-in scrolling support.
404
+
405
+ Example:
406
+
407
+ ```python
408
+ scrollable = plp.Scrollable()
409
+ scrollable.parent = panel
410
+ ```
411
+
412
+ ---
413
+
414
+ # Logging
415
+
416
+ PlayPy replaces standard exceptions/logging with a categorized logging system.
417
+
418
+ ```python
419
+ plp.log(severity, category, message)
420
+ ```
421
+
422
+ Severities:
423
+
424
+ ```python
425
+ plp.Severity.INFO
426
+ plp.Severity.WARNING
427
+ plp.Severity.ERROR
428
+ plp.Severity.CRITICAL
429
+ ```
430
+
431
+ `ERROR` and `CRITICAL` are treated as `NoReturn`.