mirror of
https://github.com/pyscript/pyscript.git
synced 2026-03-24 11:00:38 -04:00
Adding __terminal__ reference on terminal scripts (#1947)
This commit is contained in:
committed by
GitHub
parent
7ad7f0abfb
commit
cea52b4334
@@ -62,3 +62,14 @@ test('MicroPython + configURL', async ({ page }) => {
|
||||
await page.goto('http://localhost:8080/test/config-url.html');
|
||||
await page.waitForSelector('html.main.worker');
|
||||
});
|
||||
|
||||
test('Pyodide + terminal on Main', async ({ page }) => {
|
||||
await page.goto('http://localhost:8080/test/py-terminal-main.html');
|
||||
await page.waitForSelector('html.ok');
|
||||
});
|
||||
|
||||
|
||||
test('Pyodide + terminal on Worker', async ({ page }) => {
|
||||
await page.goto('http://localhost:8080/test/py-terminal-worker.html');
|
||||
await page.waitForSelector('html.ok');
|
||||
});
|
||||
|
||||
14
pyscript.core/test/py-terminal-main.html
Normal file
14
pyscript.core/test/py-terminal-main.html
Normal file
@@ -0,0 +1,14 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>PyTerminal Main</title>
|
||||
<link rel="stylesheet" href="../dist/core.css">
|
||||
<script type="module" src="../dist/core.js"></script>
|
||||
<style>.xterm { padding: .5rem; }</style>
|
||||
</head>
|
||||
<body>
|
||||
<py-script src="terminal.py" terminal></py-script>
|
||||
</body>
|
||||
</html>
|
||||
14
pyscript.core/test/py-terminal-worker.html
Normal file
14
pyscript.core/test/py-terminal-worker.html
Normal file
@@ -0,0 +1,14 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>PyTerminal Main</title>
|
||||
<link rel="stylesheet" href="../dist/core.css">
|
||||
<script type="module" src="../dist/core.js"></script>
|
||||
<style>.xterm { padding: .5rem; }</style>
|
||||
</head>
|
||||
<body>
|
||||
<py-script src="terminal.py" worker terminal></py-script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -14,6 +14,9 @@
|
||||
print('hello world')
|
||||
</script>
|
||||
<py-script worker terminal>
|
||||
# works on both worker and main scripts
|
||||
print("__terminal__", __terminal__)
|
||||
|
||||
import sys
|
||||
from pyscript import display, document
|
||||
display("Hello", "PyScript Next - PyTerminal", append=False)
|
||||
|
||||
8
pyscript.core/test/terminal.py
Normal file
8
pyscript.core/test/terminal.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from pyscript import document
|
||||
|
||||
classList = document.documentElement.classList
|
||||
|
||||
if not __terminal__:
|
||||
classList.add("error")
|
||||
else:
|
||||
classList.add("ok")
|
||||
Reference in New Issue
Block a user