Introduction

Installation

Limitations of the "file" protocol

Frequently asked questions

Syntax, keywords and built-in functions

Standard distribution

import implementation

Brython packages

Browser interface

Introduction - DOM API
Creating a document
Accessing elements
Attributes, properties and methods

Events
Mouse events
Keyboard events
Focus events
Drag events

Query string

Interactions with Javascript

Brython-specific built-in modules

browser
browser.aio
browser.ajax
browser.html
browser.local_storage
browser.markdown
browser.object_storage
browser.session_storage
browser.svg
browser.template
browser.timer
browser.webcomponent
browser.websocket
browser.worker

Widgets
browser.widgets.dialog
browser.widgets.menu

interpreter
javascript

Working with Brython

Execution options
Testing and debugging
Deploying an application

Cookbook

Hello world !
Insert content in an element
HTML markup (bold,italic...)
HTML table
Bind and unbind events
Handle options in a SELECT
Drag and drop
Get the content of an element
Read the content of a file
Store objects locally
Example of onmouseover
 

Brython packages

A "Brython package" can be loaded in the HTML page to give access to importable modules. It consists in a file with the extension .brython.js containing the modules and packages to distribute; it is inserted by the usual syntax

<script src="http://anyhost/path/package_name.brython.js"></script>

Brython packages can be located on any server, making their deployment and usage very straightforward.

To generate a Brython package, use the CPython brython package. In the directory where the modules and packages to distribute stand, run:

brython-cli make_package <package_name>

If the directory contains a file __init.py__, the modules will be relative to the package. For instance, if the directory structure is

__init__.py
dialog.py
menu.py

and we want to generate package widgets from this directory, then modules will be imported by

import widgets.dialog
from widgets import menu

If the directory does not contain __init__.py, the modules will be imported by their name. So if it only contains

dialog.py
menu.py

the modules will be imported by

import dialog
import menu