3

I was wandering through the docs of pygbag, and I couldn't find how the python scripts are actually executed from the browser.

I made a test project to look how the files created by pygbag looked like, but I couldn't really figure out what role the index.html exactly plays. It seemed to me like I couldn't find any script in it, so I supposed that it could be directly interpreted, but I'm not really sure.

There is a python script in the html file, and I found one line which seems to run the main program : await shell.runpy(main, callback=ui_callback), but I don't know whether it just executes the python script in the folder or if the script is somewhere compiled in this file.

Could anyone explain me ?

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
Martin_Who
  • 31
  • 4

1 Answers1

0

I think it would be really great if they cleaned up the project or added more docs so that the wasm build process is easier to understand and expand on.

I also looked through the index.html page and tried to do a similar thing to what you are asking about. From what I understand, there’s an Android web assembly file being built out of the python code, then it’s being run in the in the index.html file in like an iFrame or canvas (I apologize, I am not a front end expert). I believe the pyscript stuff is for communicating to/from the python WASM file. I do not believe that the pygame itself is being interpreted because it would likely be way way slower and too inefficient to run this way. I have had no performance issues running a test game I made in the browser.

I personally really appreciate pygbag, and I would love to see it become even easier/better to embed pygame in the browser. I feel like more docs & contributions would help a lot. However, I am also a little concerned about the security of this package. I would feel a lot more comfortable contributing and using it if it had a 95+ trust score on package rating sites!

Hope this can help you!