How to import library using Brython

You need to include brython_stdlib.js in your html code. So your html should look like this:

<html>
    <head>
        <script src="https://stackoverflow.com/questions/40001634/src/Brython3.2.8/brython.js"></script>
        <script src="../src/Brython3.2.8/brython_stdlib.js"></script>
    </head>
    <body onload="brython()">
        <script type="text/python">
            import sys
            from browser import document, alert

            def echo(ev):
                alert(document["zone"].value)

            document['mybutton'].bind('click', echo)
        </script>
        <input id="zone"><button id="mybutton">click !</button>
   </body>
</html>

Leave a Comment