Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b22f384

Browse filesBrowse files
PyGame - TOML + JSON absolute URL + input patch (#2313)
* Make config URL canonical * Better baseURL + input patch
1 parent caeab77 commit b22f384
Copy full SHA for b22f384

File tree

Expand file treeCollapse file tree

5 files changed

+17
-5
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+17
-5
lines changed

‎core/package-lock.json

Copy file name to clipboardExpand all lines: core/package-lock.json
+2-2Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎core/package.json

Copy file name to clipboardExpand all lines: core/package.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pyscript/core",
3-
"version": "0.6.36",
3+
"version": "0.6.39",
44
"type": "module",
55
"description": "PyScript",
66
"module": "./index.js",

‎core/src/plugins/py-game.js

Copy file name to clipboardExpand all lines: core/src/plugins/py-game.js
+13-1Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ import { getText } from "../fetch.js";
1111

1212
const progress = createProgress("py-game");
1313

14+
const inputPatch = `
15+
import builtins
16+
def input(prompt=""):
17+
import js
18+
return js.prompt(prompt)
19+
20+
builtins.input = input
21+
del builtins
22+
del input
23+
`;
24+
1425
let toBeWarned = true;
1526

1627
const hooks = {
@@ -45,7 +56,7 @@ const hooks = {
4556
progress,
4657
wrap.interpreter,
4758
config,
48-
url || location.href,
59+
url ? new URL(url, location.href).href : location.href,
4960
);
5061
}
5162

@@ -63,6 +74,7 @@ const hooks = {
6374
});
6475

6576
await wrap.interpreter.runPythonAsync(stdlib);
77+
wrap.interpreter.runPython(inputPatch);
6678

6779
let code = dedent(script.textContent);
6880
if (script.src) code = await fetch(script.src).then(getText);

‎core/tests/manual/game/config.toml

Copy file name to clipboardExpand all lines: core/tests/manual/game/config.toml
Whitespace-only changes.

‎core/tests/manual/game/index.html

Copy file name to clipboardExpand all lines: core/tests/manual/game/index.html
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<script type="module" src="../../../dist/core.js"></script>
99
</head>
1010
<body>
11-
<script type="py-game" src="aliens.py" config="{}"></script>
11+
<script type="py-game" src="aliens.py" config="./config.toml"></script>
1212
<div class="demo">
1313
<div class="demo-header">pygame.examples.aliens</div>
1414
<div class="demo-content">

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.