Introduction

Installation

Frequently asked questions

Syntax, keywords and built-in functions

Standard distribution

import implementation

Browser interface

Brython-specific built-in modules

Working with Brython

Brython for Firefox OS

Cookbook

 

The package browser groups the built-in Brython-specific names and modules

browser.alert(message)
a function that prints the message in a pop-up window. Returns None

browser.confirm(message)
a function that print the message in a window, and two buttons (ok/cancel). Returns True if ok, False if cancel

browser.console
an object with methods to interact with the browser console. Its interface is browser-specific. It exposes at least the method log(msg), which prints the message msg in the console

browser.document
an object that represents the HTML document currently displayed in the browser window. The interface of this object is described in section "Browser interface"

browser.DOMEvent
the class of DOM events

browser.DOMNode
the class of DOM nodes

browser.load(script_url)
Load the Javascript library at address script_url.

This function uses a blocking Ajax call. It must be used when one can't load the Javascript library in the html page by <script src="prog.js"></script>.

The names inserted by the library inside the global Javascript namespace are available in the Brython script as attributes of the window object.

For instance, the module jqueryui in Brython standard library provides an interface with the Javascript library jQueryUI. To use it in a Brython script, you simply write import jqueryui without inserting the Javascript libraries in the page. It's the module jqueryui that loads them, using this function load()

browser.prompt(message[,default])
a function that prints the message in a window, and an entry field. Returns the entered value ; if no value was entered, return default if defined, else the empty string

browser.window
an object that represents the browser window