IntroductionInstallationLimitations of the "file" protocolFrequently asked questionsSyntax, keywords and built-in functionsStandard distributionimport implementationBrython packagesBrowser 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 BrythonCookbook |
Brython packagesA "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.pyand we want to generate package widgets from this directory, then
modules will be imported by
import widgets.dialog from widgets import menuIf the directory does not contain __init__.py , the modules will be
imported by their name. So if it only contains
dialog.py menu.pythe modules will be imported by import dialog import menu |