Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-hippo committed Jan 20, 2024
2 parents fce0566 + 0939043 commit e71539b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,21 @@ Useful .gitignore additions:
- [Pygbag code examples](https://pygame-web.github.io/wiki/pygbag-code/#pygbag-code-specifics-samples-)
- [List of available wheels](https://pygame-web.github.io/wiki/pkg/)

When importing complex packages (for example, numpy or matplotlib), you must put their import statements at top of main.py.
When importing complex packages (for example, numpy or matplotlib), you must put their import statements at top of `main.py`. You should also add a metadata header as specified by [PEP 723](https://peps.python.org/pep-0723/), for example:
```
# /// script
# dependencies = [
# "six",
# "bs4",
# "markdown-it-py",
# "pygments",
# "rich",
# "mdurl",
# "textual",
# ]
# requires-python = ">=3.11"
# ///
```

If using pygame-zero (mostly untested), put `#!pgzrun` near the top of main.py. (2nd line is perfect if the file already has a shebang)

Expand Down
18 changes: 13 additions & 5 deletions wiki/pkg/panda3d/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import panda3d.core as p3d
ShowBase.run() must be patched because it is not async, for convenience
pygbag runtime applies a monkey-patch to do that automatically.
But if you use taskMgr.step() or use the wheel in your own python runtime then you should do it that way:
```py
```python
async def main():
while True:
taskMgr.step()
Expand Down Expand Up @@ -58,7 +58,7 @@ note: preferably use a 1024x600 screen size.

so my original code uses this kind of mainloop:

```
```python
def main():
W = Wrapper()
while True:
Expand All @@ -72,9 +72,17 @@ if __name__=="__main__":

Which has the advantage that it's "obvious" where the main loop takes place. `W.main` is performing the steps defined by the programmer/user and `W.b.taskMgr.step()` executes all the engine functionality, like rendering.

this is changed to
this is changed to, note the PEP 723 block to tell the runtime you will use Panda3D wasm wheel so it gets downloaded
and installed.

```python

# /// script
# dependencies = [
# "panda3d",
# ]
# ///

```
async def main(): # this one defines the main as async
W = Wrapper()
while True:
Expand All @@ -89,7 +97,7 @@ if __name__=="__main__":

with an additional import of

```
```python
import pygbag.aio as asyncio
```

Expand Down

0 comments on commit e71539b

Please sign in to comment.