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

 

Problem

Use the basic HTML markup : bold, italic, headers...

Solution

from browser import document, html

document['zone'] <= html.H1("Introducing Brython")
document['zone'] <= html.H4(html.I("Python in the browser"))
document['zone'] <= html.B("Hello world !")

Initial content

B is a function defined in the module browser.html, matching the HTML tag <B> (bold)

B("text") returns an object matching the HTML <b>text</b>

All HTML tags have their own function : I, H1, H2,.... You can nest functions, as shown in the second line :

document <= html.H4(html.I("Python in the browser"))