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
 

Introduction

For the interface with the browser, Brython is compliant with the Document Object Model interface, which is widely documented on the web :

This interface is language-independent. With Brython, all the operations described in the DOM API rely on two objects defined in the module browser : document and window

document implements the interface Document defined in the DOM API. For instance, it supports the following methods :

document.getElementById(elt_id)

returns a reference to the DOM element whose id is elt_id

document.createElement(tagName)

returns a new element of type tagName ; for instance, to create an hypertext link :

link = document.createElement('A')

document.appendChild(elt)

add the element elt to the document

Besides this standard interface, Brython propose an alternative interface, more familiar for Brython developers. It is described in the following pages