Skip to content

Commit 9a6c3f6

Browse files
authored
update downloading files from python to more directly answer question
1 parent 3205a45 commit 9a6c3f6

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

wiki/pygbag-code/README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,15 @@ print( json.dumps(repo["packages"], sort_keys=True, indent=4) )
8888
implemented, event based, TODO sample
8989

9090
### downloading files created by python
91-
Python files can still be created normally and will appear in the browser's filesystem.
91+
Python files can still be created normally and will appear in the browser's filesystem. They can then be downloaded from the browser's filesystem to a user's filesystem with `platform.window.MM.download(filepath)`.
9292
```py
93-
# example
93+
import sys, platform
9494
with open("file.txt", "w") as f:
95-
f.write("newly created file")
96-
```
97-
98-
Downloading these files from the browser's filesystem to a user's filesystem is possible through pygbag's debug repl.
99-
Ways to do so are available in the [debug repl's wiki page](https://pygame-web.github.io/wiki/pygbag-debug/).
95+
f.write("newly created example file")
96+
if sys.platform == "emscripten":
97+
platform.window.MM.download("file.txt")
10098
```
99+
`platform.window.MM.download("file.txt")` is code taken from the debug REPL's shell implementation. Read about the debug REPL [here](https://pygame-web.github.io/wiki/pygbag-debug/).
101100

102101
### editing local files
103102

0 commit comments

Comments
 (0)