Coder Social home page Coder Social logo

unkvuzutop / brython Goto Github PK

View Code? Open in Web Editor NEW

This project forked from brython-dev/brython

0.0 1.0 0.0 54.57 MB

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

License: BSD 3-Clause "New" or "Revised" License

Python 57.94% Makefile 0.01% Shell 0.01% JavaScript 22.10% HTML 19.72% CSS 0.06% Roff 0.08% Visual Basic 0.01% PLSQL 0.09%

brython's Introduction

Stories in Ready Travis

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 type="text/javascript" src="/path/to/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

Zero install !

The most simple way to get started, without anything to install, is to use the distribution available online through rawgit. You can either choose the latest stable release :

<script type="text/javascript"
    src="https://cdn.rawgit.com/brython-dev/brython/stable/www/src/brython.js">
</script>

or the current development version :

<script type="text/javascript" 
    src="https://cdn.rawgit.com/brython-dev/brython/master/www/src/brython.js">
</script>

The previous code will allow you to use raw python code, but if you import modules from the standard library this will be slow as they are implemented using ajax calls. Besides brython.js you can load a single javascript file with the available stdlib:

<script type="text/javascript"
    src="https://cdn.rawgit.com/brython-dev/brython/stable/www/src/brython_stdlib.js">
</script>

or the current development version :

<script type="text/javascript" 
    src="https://cdn.rawgit.com/brython-dev/brython/master/www/src/brython_stdlib.js">
</script>

Local install

To install Brython locally, if you have a CPython distribution with pip :

pip install brython

then create a new directory and run

python -m brython --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.

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 and Spanish.

The most updated docs usually are the English and French versions so if you want to be up-to-date, please, use these versions.

Curious about how Brython works ?

Community (questions, feedback, issues, new features, ...)

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.

There's a Brython Community on Google Plus.

IRC: #brython on freenode

Agile Development

Throughput Graph

Thank you

  • BrowserStack for providing an access to their online testing environment.

brython's People

Contributors

alanjds avatar amrdraz avatar aventine1 avatar bearney74 avatar brollb avatar caryoscelus avatar cben avatar cforger avatar chachegs avatar dawsbot avatar dirkk0 avatar enforcer avatar ernest0x avatar glyph avatar h4ck3rm1k3 avatar joaoventura avatar jonathanverner avatar jsbueno avatar juancarlospaco avatar kikocorreoso avatar mementum avatar mrwwalmsley avatar olemis avatar p-i- avatar perkinslr avatar pierrequentel avatar qsantos avatar quentinvaut avatar rdb avatar rovitotv avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.