@pytincture/runtime
v0.9.27
Published
Standalone pytincture.js runtime with inline app auto-start support.
Downloads
122
Maintainers
Readme
@pytincture/runtime
Standalone build of pytincture.js, the Pyodide bootstrapper used by the pytincture framework. It can be loaded directly from a CDN to run embedded Python snippets (or zipped pytincture apps) with no backend.
Usage
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/@pytincture/[email protected]/dist/pytincture.min.js"></script>
</head>
<body>
<div id="maindiv" style="width:100%;height:100vh;"></div>
<script type="text/json" id="micropip-libs">
["faker"]
</script>
<script type="text/python">
from dhxpyt.layout import MainWindow
class Demo(MainWindow):
def load_ui(self):
self.set_theme("dark")
print("Demo loaded!")
</script>
</body>
</html>What happens:
- The runtime loads Pyodide (default
https://cdn.jsdelivr.net/pyodide/v0.28.0/full/). - Installs
micropipand any extra wheels listed in#micropip-libs. - Installs the default widget library (
dhxpyt) or another package you configure. - Auto-detects
<script type="text/python">blocks, mounts them under/appcode, finds aMainWindowsubclass (or explicit entrypoint), and runs it. - Errors are printed to the console and rendered inside
#maindivwhen present.
Configuration
Before the script tag loads, you may set the following globals:
<script>
window.pytinctureAutoStartConfig = {
widgetlib: "dhxpyt",
libsSelector: "#micropip-libs",
pyodideBaseUrl: "https://cdn.jsdelivr.net/pyodide/v0.28.0/full/",
enableBackendLogging: false
};
// Disable auto-start if you want to call runTinctureApp manually:
// window.pytinctureAutoStartDisabled = true;
</script>
<script src="https://cdn.jsdelivr.net/npm/@pytincture/runtime/dist/pytincture.min.js"></script>Manual start (if auto-start is disabled):
runTinctureApp({
mode: "inline",
widgetlib: "dhxpyt",
enableBackendLogging: false
});Development
This package lives inside the main pytincture repository:
cd pytincture/frontend
npm install
npm run build # emits dist/pytincture.{js,min.js,esm.js}
npm run build:watch # rebuild on changesnpm run build automatically syncs the package.json version with the Python framework (pytincture/__init__.__version__), so npm releases always match the backend version.
Publishing
From the repo root you can run:
bash scripts/publish_runtime.shThe helper script:
- Reads the framework version.
- Installs dependencies & syncs package.json.
- Builds the bundles.
- Publishes to npm if that version isn’t already available.
Once published, load from jsDelivr/UNPKG:
<script src="https://cdn.jsdelivr.net/npm/@pytincture/[email protected]/dist/pytincture.min.js"></script>Replace 0.9.20 with the framework version you need, or omit it to use @latest.
