yakkomajuri /
brython-snake
A web snake game built 100% with Python for the browser.
69/100 healthLoading repository data…
brython-dev / repository
Brython (Browser Python) is an implementation of Python 3 running in the browser
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
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="/path/to/brython.js"></script>
</head>
<body>
<script type="text/python">
from browser import bind, document, alert
@bind(document['mybutton'], 'click')
def echo(event):
alert(document["zone"].value)
</script>
<input id="zone"><button id="mybutton">click !</button>
</body>
</html>
To use Brython, all there is to do is:
<script type="text/python">.Brython supports the syntax of Python 3, and the modules of the CPython distribution written in Python, except for the features that are not relevant in the browser context (writing on disk for instance).
Since version 3.8.0, Brython implements the Python version of the same major / minor version number.
It includes libraries to interact with DOM elements and events, and with existing Javascript libraries such as jQuery, D3, Highcharts, Raphael etc. It supports the latest specs of HTML5/CSS3, and can use CSS Frameworks like Bootstrap3, LESS, SASS etc.
The most simple way to get started, without anything to install, is to use the distribution available online through jsDelivr. You can choose the latest stable release :
<script src="https://cdn.jsdelivr.net/npm/brython@3.14.3/brython.min.js">
</script>
The previous code will allow you to use raw python code, but if you import modules from the standard library you have to load a single javascript file with the available stdlib:
<script src="https://cdn.jsdelivr.net/npm/brython@3.14.3/brython_stdlib.js">
</script>
jsDelivr supports version ranges, so if you want the latest of the 3.14.x versions:
<script src="https://cdn.jsdelivr.net/npm/brython@3.14/brython.min.js">
</script>
<script src="https://cdn.jsdelivr.net/npm/brython@3.14/brython_stdlib.js">
</script>
or the latest of the 3.x.y versions:
<script src="https://cdn.jsdelivr.net/npm/brython@3/brython.min.js">
</script>
<script src="https://cdn.jsdelivr.net/npm/brython@3/brython_stdlib.js">
</script>
If you want to use the latest development version, you can load these scripts instead:
<script src="https://raw.githack.com/brython-dev/brython/master/www/src/brython.js"
crossorigin="anonymous">
</script>
<script src="https://raw.githack.com/brython-dev/brython/master/www/src/brython_stdlib.js"
crossorigin="anonymous">
</script>
To install Brython locally, if you have a CPython distribution with pip :
pip install brython
then create a new directory and run
brython-cli install
or by loading the latest version of the Brython zip file from the releases page.
In both cases, the distribution includes brython.js (the core Brython engine) and brython_stdlib.js (a bundle of all the files in the standard distribution).
It also includes the page demo.html that shows a few examples of how you can interact with a web page using Python as the scripting language : create new elements, access and modify existing elements, create graphics, animations, send Ajax requests, etc.
If you want to test Brython online you can visit the following:
There is a gallery of examples where you can see simple and advanced examples using vanilla Brython or interacting with Javascript libraries.
You can start by reading the official Brython tutorial.
Full documentation is available on the official site. You can read the docs in English and French.
Curious about how Brython works ?
A tutorial explains how to build Android applications with Brython.
You can also Ask Brython Guru, it is a Brython-focused AI to answer your questions.
You can subscribe and post to the mailing list.
If you find a bug/issue or do you want to see a new feature in Brython, please, open a new issue.
If you want to contribute to Brython, please read the contributing guide.
Selected from shared topics, language and repository description—not editorial ratings.
yakkomajuri /
A web snake game built 100% with Python for the browser.
69/100 healthbmsleight /
An attempt to have blocks running, from the browser using Python
42/100 healthMarketingPipeline /
Examples & resources on how to use Python in the web browser.
dirkk0 /
An interactive playground for Brython: Python as a scripting language for browsers.
40/100 healthPierreQuentel /
Create and run a slideshow in the browser with Brython (Python in the browser)
39/100 healthArcTanSusan /
Python in the Browser: Intro to Brython PyCon'14 talk. Contains demos and slides.
29/100 health