pyjs-examples 0.0.1__py3-none-any.whl
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.
- pyjs_examples/__init__.py +1 -0
- pyjs_examples/calculator/README.md +55 -0
- pyjs_examples/calculator/__init__.py +1 -0
- pyjs_examples/calculator/__main__.py +9 -0
- pyjs_examples/calculator/calculator.py +325 -0
- pyjs_examples/calculator/tests/test_browser_calculator.py +67 -0
- pyjs_examples/calculator/tests/test_calculator.py +72 -0
- pyjs_examples/catalog.py +1433 -0
- pyjs_examples/chatroom/README.md +50 -0
- pyjs_examples/chatroom/__init__.py +1 -0
- pyjs_examples/chatroom/__main__.py +12 -0
- pyjs_examples/chatroom/chat_server.py +156 -0
- pyjs_examples/chatroom/chatroom.py +704 -0
- pyjs_examples/chatroom/tests/test_browser_chatroom.py +59 -0
- pyjs_examples/chatroom/tests/test_chat_server.py +53 -0
- pyjs_examples/chatroom/visual_test.py +156 -0
- pyjs_examples/counter.py +73 -0
- pyjs_examples/kanban/README.md +31 -0
- pyjs_examples/kanban/__init__.py +1 -0
- pyjs_examples/kanban/__main__.py +8 -0
- pyjs_examples/kanban/kanban.py +581 -0
- pyjs_examples/kanban/tests/renders/kanban-board.png +0 -0
- pyjs_examples/kanban/tests/test_browser_kanban.py +150 -0
- pyjs_examples/kanban/tests/test_kanban.py +38 -0
- pyjs_examples/kanban/visual_test.py +108 -0
- pyjs_examples/nativescript_counter/README.md +31 -0
- pyjs_examples/nativescript_counter/__init__.py +5 -0
- pyjs_examples/nativescript_counter/__main__.py +17 -0
- pyjs_examples/nativescript_counter/counter.py +54 -0
- pyjs_examples/nativescript_counter/tests/test_android_counter.py +31 -0
- pyjs_examples/nativescript_counter/tests/test_counter.py +11 -0
- pyjs_examples/samples/__init__.py +1 -0
- pyjs_examples/samples/state_counter/README.md +19 -0
- pyjs_examples/samples/state_counter/__init__.py +1 -0
- pyjs_examples/samples/state_counter/__main__.py +3 -0
- pyjs_examples/samples/state_counter/state_counter.py +60 -0
- pyjs_examples/samples/state_counter/tests/test_browser_state_counter.py +18 -0
- pyjs_examples/samples/state_counter/tests/test_state_counter.py +17 -0
- pyjs_examples/samples/ui_dialog/README.md +19 -0
- pyjs_examples/samples/ui_dialog/__init__.py +1 -0
- pyjs_examples/samples/ui_dialog/__main__.py +3 -0
- pyjs_examples/samples/ui_dialog/tests/test_browser_ui_dialog.py +21 -0
- pyjs_examples/samples/ui_dialog/tests/test_ui_dialog.py +10 -0
- pyjs_examples/samples/ui_dialog/ui_dialog.py +65 -0
- pyjs_examples/space_invaders/README.md +45 -0
- pyjs_examples/space_invaders/__init__.py +1 -0
- pyjs_examples/space_invaders/__main__.py +3 -0
- pyjs_examples/space_invaders/space_invaders.py +1025 -0
- pyjs_examples/space_invaders/tests/renders/action_scene.png +0 -0
- pyjs_examples/space_invaders/tests/renders/initial_wave.png +0 -0
- pyjs_examples/space_invaders/tests/test_browser_game.py +86 -0
- pyjs_examples/space_invaders/tests/test_game.py +83 -0
- pyjs_examples/todomvc/README.md +50 -0
- pyjs_examples/todomvc/__init__.py +1 -0
- pyjs_examples/todomvc/__main__.py +12 -0
- pyjs_examples/todomvc/base.css +141 -0
- pyjs_examples/todomvc/index.css +393 -0
- pyjs_examples/todomvc/tests/test_browser_todomvc.py +145 -0
- pyjs_examples/todomvc/tests/test_todomvc.py +84 -0
- pyjs_examples/todomvc/todomvc.py +426 -0
- pyjs_examples/workspace/README.md +25 -0
- pyjs_examples/workspace/__init__.py +1 -0
- pyjs_examples/workspace/__main__.py +3 -0
- pyjs_examples/workspace/tests/test_browser_workspace.py +109 -0
- pyjs_examples/workspace/tests/test_workspace.py +27 -0
- pyjs_examples/workspace/workspace.py +749 -0
- pyjs_examples-0.0.1.dist-info/METADATA +71 -0
- pyjs_examples-0.0.1.dist-info/RECORD +71 -0
- pyjs_examples-0.0.1.dist-info/WHEEL +5 -0
- pyjs_examples-0.0.1.dist-info/entry_points.txt +11 -0
- pyjs_examples-0.0.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
from pyjs import js
|
|
2
|
+
from pyjs.web.domx import CustomElement, ref, tag, tw
|
|
3
|
+
from pyjs.web.ui.dialog import (
|
|
4
|
+
Dialog,
|
|
5
|
+
DialogClose,
|
|
6
|
+
DialogContent,
|
|
7
|
+
DialogDescription,
|
|
8
|
+
DialogFooter,
|
|
9
|
+
DialogHeader,
|
|
10
|
+
DialogTitle,
|
|
11
|
+
DialogTrigger,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@js
|
|
16
|
+
class DialogSample(CustomElement):
|
|
17
|
+
def __init__(self):
|
|
18
|
+
super().__init__()
|
|
19
|
+
self.close_button = ref(DialogClose("Close"))
|
|
20
|
+
self.dialog = ref(
|
|
21
|
+
Dialog(
|
|
22
|
+
DialogTrigger("Open dialog"),
|
|
23
|
+
DialogContent(
|
|
24
|
+
"Welcome to PyJS",
|
|
25
|
+
DialogHeader(
|
|
26
|
+
DialogTitle("Welcome to PyJS"),
|
|
27
|
+
DialogDescription(
|
|
28
|
+
"This accessible modal is implemented with native browser APIs."
|
|
29
|
+
),
|
|
30
|
+
),
|
|
31
|
+
DialogFooter(self.close_button),
|
|
32
|
+
),
|
|
33
|
+
)
|
|
34
|
+
)
|
|
35
|
+
tag(
|
|
36
|
+
self,
|
|
37
|
+
tag(
|
|
38
|
+
"main",
|
|
39
|
+
tw("grid min-h-screen place-items-center bg-slate-50 font-sans text-slate-950"),
|
|
40
|
+
tag(
|
|
41
|
+
"section",
|
|
42
|
+
tw(
|
|
43
|
+
"w-full max-w-md rounded-xl border border-slate-200 "
|
|
44
|
+
"bg-white p-8 text-center shadow-lg"
|
|
45
|
+
),
|
|
46
|
+
tag("h1", tw("mb-2 text-2xl font-semibold"), "Native dialog"),
|
|
47
|
+
tag(
|
|
48
|
+
"p",
|
|
49
|
+
tw("mb-6 text-sm leading-6 text-slate-500"),
|
|
50
|
+
"Open the dialog to see focus management and accessible modal behavior.",
|
|
51
|
+
),
|
|
52
|
+
self.dialog,
|
|
53
|
+
),
|
|
54
|
+
),
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def main():
|
|
59
|
+
return DialogSample()
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
if __name__ == "__main__":
|
|
63
|
+
from pyjs.server import serve
|
|
64
|
+
|
|
65
|
+
serve("ui_dialog")
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Void Patrol
|
|
2
|
+
|
|
3
|
+
Void Patrol is a compact Space Invaders-style WebGPU game implemented in Python and
|
|
4
|
+
transpiled to JavaScript by pyjs.
|
|
5
|
+
|
|
6
|
+
It demonstrates:
|
|
7
|
+
|
|
8
|
+
- deterministic game-state updates that run in Python and JavaScript
|
|
9
|
+
- a WebGPU renderer using dynamic vertex buffers and direction-aware, depth-tested geometry
|
|
10
|
+
- keyboard controls and a request-animation-frame game loop
|
|
11
|
+
- score, lives, wave progression, collisions, and restart behavior
|
|
12
|
+
- observable summary state mirrored onto custom-element DOM attributes
|
|
13
|
+
- browser render regression testing against a stored PNG
|
|
14
|
+
|
|
15
|
+
## Run the game
|
|
16
|
+
|
|
17
|
+
From the repository root:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
.venv/bin/python -m pyjs_examples.space_invaders
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Open `http://127.0.0.1:8000/`. Move with the arrow keys or A/D, fire with Space,
|
|
24
|
+
and press Enter to restart after game over.
|
|
25
|
+
|
|
26
|
+
## Run the tests
|
|
27
|
+
|
|
28
|
+
Run the deterministic state tests with Python:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
.venv/bin/python -m pytest -q examples/space_invaders/tests
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Run the same tests and the WebGPU render test in a browser:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
.venv/bin/python -m pytest -q examples/space_invaders/tests --pyjs-target=web
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
To create or intentionally replace the expected render:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
.venv/bin/python -m pytest -q examples/space_invaders/tests/test_browser_game.py \
|
|
44
|
+
--pyjs-target=web --pyjs-update-renders
|
|
45
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""A complete WebGPU game with model, browser, and visual tests."""
|