mirror of
https://github.com/pyscript/pyscript.git
synced 2026-02-13 07:01:00 -05:00
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
This commit is contained in:
committed by
GitHub
parent
8b6b055681
commit
40e99abbdf
53
pyscript.core/test/py-editor.html
Normal file
53
pyscript.core/test/py-editor.html
Normal file
@@ -0,0 +1,53 @@
|
||||
<!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>
|
||||
Reference in New Issue
Block a user