Sketchingpy can go anywhere your web development can take you. Unlike desktop Python, requirements are crafted directly in the web document itself. If you haven't written HTML before, we suggest the
Mozilla Developer Network's introduction. With that, here's a minimal example:
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<!-- PyScript -->
<link rel="stylesheet" href="https://pyscript.net/releases/2023.11.2/core.css">
<script type="module" src="https://pyscript.net/releases/2023.11.2/core.js"></script>
</head>
<body>
<py-config>
{
"packages": ["sketchingpy==0.1.8"]
}
</py-config>
<!-- You may need to change this ID to match your code. -->
<div id="sketch-load-message">Loading...</div>
<canvas id="sketch-canvas"></canvas>
<!-- You can link the script as shown below or use py-script to inline -->
<script type="py" src="main.py"></script>
</body>
</html>
This will work with the defaults:
<script type="py">
sketch = sketchingpy.Sketch2DWeb(width, height)
</script>
Note that the CDN above uses sources from other open source projects including those from the PyScript project subject to their permissive
license. Regardless, for more configuration details including self-hosting, multiple Python files, and web fonts see,
detailed web instructions.