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 |
Execution optionsA number of options are available to customize script execution. They can be defined at the HTML page level, or by script.Defining optionsDeclaring options for the whole page is done through the attributes of a specific HTML tag<brython-options> . This tag should be placed preferably in
section <body> of the document, not in <head> .
For instance, to define the options debug and cache :
<brython-options debug="1" cache="true"> </brython-options>To define an option for a specific script, use the attribute of the <script>
tag:
<script type="text/python" debug="2"> Options only available at page levelidsby default, all the scripts in the page are executed. This options specifies a list of scripts to execute, as a space-separated list of identifiers (attribute indexedDB<brython-options ids="scriptA scriptB"></brython-options>
specifies if the program can use the indexedDB database to
store a compiled version of the modules located in brython_stdlib.js
or brython_modules.js. Defaults to
Options available at page or script levelAn option defined at script level (attribute of<script> ) has precedence
over the same option defined at page level (attribute of <brython-options> ).
args
equivalent to command-line arguments, available in programs by
cache
if set todebug : the debug mode
a space-separated list of paths where imported modules should be searchedstatic_stdlib_import
boolean, indicates if, in order to import modules or packages from the
standard library, the static mapping table in the script
stdlib_paths.js should be used. Defaults to
The function brython(options)In Brython versions prior to 3.12, options could only be defined for all the scripts in the page as an argument to the functionbrython() , explicitely
called on page load by the syntax
<body onload="brython({debug: 2})">For backwards compatibility, this syntaxe remains usable in version 3.12. If a page defined a tag <brython-options> , the values passed to function
brython() replace those of the tag.
|