Files
pyscript/pyscript.core/test/py-editor.html
Andrea Giammarchi 40e99abbdf Py editor (#1860)
* added a *py-editor* plugin based on *codemirror*
  * use a `<script type="py-editor">` wrapper to bootstrap code
  * tested that all is good via smoke-test in test/py-editor.html
2023-12-06 09:53:10 +01:00

54 lines
1.5 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>PyTerminal</title>
<link rel="stylesheet" href="../dist/core.css">
<script type="module" src="../dist/core.js"></script>
<style>
.py-editor-box, .mpy-editor-box {
padding: .5rem;
position: relative;
}
.py-editor-run-button, .mpy-editor-run-button {
position: absolute;
right: .5rem;
top: .5rem;
opacity: 0;
transition: opacity .25s;
}
.py-editor-box:hover .py-editor-run-button,
.mpy-editor-box:hover .mpy-editor-run-button,
.py-editor-run-button:focus,
.py-editor-run-button:disabled,
.mpy-editor-run-button:focus,
.mpy-editor-run-button:disabled {
opacity: 1;
}
</style>
</head>
<body>
<script type="py-editor">
import sys
print(sys.version)
</script>
<script type="mpy-editor">
import sys
print(sys.version)
a = 42
</script>
<script type="mpy-editor" env="shared">
if not 'a' in globals():
a = 1
else:
a += 1
print(a)
</script>
<script type="mpy-editor" env="shared">
# doubled a
print(a * 2)
</script>
</body>
</html>