Skip to content
/ brython Public
forked from brython-dev/brython

Brython (Browser Python) is an implementation of Python 3 running in the browser

License

Notifications You must be signed in to change notification settings

edisno/brython

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stories in Ready Join the chat at https://gitter.im/brython-dev/brython

brython

Brython (Browser Python) is an implementation of Python 3 running in the browser, with an interface to the DOM elements and events.

Here is a simple example of an HTML page running Python:

    <html>

        <head>
            <script src="/src/brython.js"></script>
        </head>

        <body onload="brython()">

            <script type="text/python">
            from browser import document, alert

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

            document['mybutton'].bind('click', echo)
            </script>

            <input id="zone"><button id="mybutton">click !</button>

        </body>

    </html>

To use Brython, all there is to do is:

  1. Load the script brython.js.
  2. Run the function brython() on page load, like <body onload=brython()>.
  3. Write Python code inside tags <script type="text/python"> or linking it.

Main features

Brython supports most of the syntax of Python 3, including comprehensions, generators, metaclasses, imports, etc. and many modules of the CPython distribution.

It includes libraries to interact with DOM elements and events, and with existing Javascript libraries such as jQuery, 3D, Highcharts, Raphael etc. It supports lastest specs of HTML5/CSS3, and can use CSS Frameworks like Bootstrap3, LESS, SASS etc.

Getting started

In the Releases section, load the latest version of the Brython site mirror, unzip it and start the built-in web server server.py. This will point your browser to http://localhost:8000/site: you access a clone of the Brython site with an online editor, a console similar to the CPython interpreter, a gallery with many examples and a comprehensive documentation.

git clone https://github.com/brython-dev/brython.git
cd brython
python server.py

Once you are familiar with the examples..., create a new folder "app" at the same level as "site" and create a file "index.html" with the HTML example above. Point the browser to http://localhost:8000/app to see the result.

Test Brython online

If you want to test Brython online you can visit the following:

Gallery of examples

There is a gallery of examples where you can see simple and advanced examples using vanilla Brython or interacting with other javascript libraries.

Documentation

Documentation is available on the official site. You can read the docs in English, French, Spanish and Portuguese. The most updated docs usually are the English and French versions so if you want to be up-to-date, please, use these versions.

Questions, feedback, issues, new features...

There is a main mail list in English. Also, you can find mail list in other languages but the activity is very low and it is recommended to use the main one in English.

If you find a bug/issue or do you want to see a new feature in Brython, please, open a new issue.

Theres a Brython Community on Google Plus.

Agile Development

Throughput Graph

About

Brython (Browser Python) is an implementation of Python 3 running in the browser

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 68.5%
  • HTML 25.4%
  • JavaScript 5.9%
  • Roff 0.1%
  • CSS 0.1%
  • R 0.0%