[x3d-public] web based python/brython x3d scripts

John Carlson yottzumm at gmail.com
Fri Jan 6 14:06:34 PST 2023


Here's what you put at the bottom of your python file, weblogo.py:


# newModel is your main X3D top-level model object.


######################################################

from browser import document

def change(event):
    src = newModel.Scene.HTML5()
    document.getElementById("zone1").html = src
    document.getElementById("zone2").text = "window.x3dom.reload();"

document["button1"].bind("click", change)


<-----------------Example HTML below---------------->


<!doctype html><html>  <head>   <meta charset="utf-8"/>    <link
rel="stylesheet" type="text/css"
href="https://www.x3dom.org/download/1.8.2/x3dom.css"></link>
<script type="text/javascript"
src="https://www.x3dom.org/download/1.8.2/x3dom-full.debug.js"></script>
   <script src="https://code.jquery.com/jquery-3.6.0.min.js"
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
crossorigin="anonymous"></script>   <script type="text/javascript"
src="brython.js"></script>   <script type="text/javascript"
src="brython_stdlib.js"></script></head><body
onload="brython(1)"><button id="button1">Press Button to Load
Scene</button><x3d
xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance"
profile="Immersive" version="3.3"
xsd:noNamespaceSchemaLocation="http://www.web3d.org/specifications/x3d-3.3.xsd"
width="300px" height="300px" backend="webgl"><scene id="zone1"
class="zone"></scene></x3d><script type="text/python"
src="weblogo.py"></script><script type="text/javascript"
id="zone2"></script></body></html>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20230106/ddcf5d58/attachment.html>


More information about the x3d-public mailing list