Differences between revisions 10 and 12 (spanning 2 versions)
Revision 10 as of 2008-11-20 21:45:47
Size: 4739
Editor: 87
Comment:
Revision 12 as of 2008-11-26 15:40:50
Size: 5725
Editor: 87
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
This topic covers ways in which python can be used in web browsers to control, create or manipulate the content within a user's web browser, or a web-based technology (such as [[http://webkit.org|webkit]], the technology behind Safari, Midori, the OLPC Browser, Adobe AIR, Google Chrome and much more; Gecko, the engine behind [[http://mozilla.com/firefox|Firefox]], XULRunner and much more; and KDE's KHTMLPart).  Specifically excluded from the list is technology that simply generates static HTML content, but technology that generates or compiles javascript definitely counts. This topic covers ways in which python can be used in web browsers to control, create or manipulate the content within a user's web browser, or a web-based technology (such as [[http://webkit.org|webkit]], the technology behind Safari, Midori, the OLPC Browser, Adobe AIR, Google Chrome and much more; Gecko, the engine behind [[http://mozilla.com/firefox|Firefox]], XULRunner and much more; and KDE's KHTMLPart).

To clarify what type of technology goes onto this page, some examples of types of technology that can and cannot be added to this section:
 *
Specifically excluded from the list is technology that simply generates static HTML content. So, an HTML pretty-printer library, as the resultant HTML simply uses the browser for "display" purposes rather than using the browser as an "application execution environment", is out.
 * Python-based technology that auto-
generates or compiles javascript definitely counts, as the resultant javascript would be executed by the web browser.
 * Technology that simply *uses* javascript or depends on javascript libraries (such as mochikit, extjs or prototype) does not count, but a python-based wrapper library around a javascript library definitely counts.

This latter example requires some further explanation: Pyjamas, for example, is a python-to-javascript compiler that can include inline javascript. So, although the input to Pyjamas is part-python, part-javascript, the output is pure-javascript that runs in a web browser, and so any such "mixed" language libraries should be included on this page.

Web Browser Programming in Python

This topic covers ways in which python can be used in web browsers to control, create or manipulate the content within a user's web browser, or a web-based technology (such as webkit, the technology behind Safari, Midori, the OLPC Browser, Adobe AIR, Google Chrome and much more; Gecko, the engine behind Firefox, XULRunner and much more; and KDE's KHTMLPart).

To clarify what type of technology goes onto this page, some examples of types of technology that can and cannot be added to this section:

  • Specifically excluded from the list is technology that simply generates static HTML content. So, an HTML pretty-printer library, as the resultant HTML simply uses the browser for "display" purposes rather than using the browser as an "application execution environment", is out.
  • Python-based technology that auto-generates or compiles javascript definitely counts, as the resultant javascript would be executed by the web browser.
  • Technology that simply *uses* javascript or depends on javascript libraries (such as mochikit, extjs or prototype) does not count, but a python-based wrapper library around a javascript library definitely counts.

This latter example requires some further explanation: Pyjamas, for example, is a python-to-javascript compiler that can include inline javascript. So, although the input to Pyjamas is part-python, part-javascript, the output is pure-javascript that runs in a web browser, and so any such "mixed" language libraries should be included on this page.

Python to Javascript Compilers

  • These are tools that convert python into javascript, that can then be run either stand-alone, using technology such as spidermonkey, google's V8 engine (for example, using pyv8), or in a web browser (where, in order to be useful, the applications must of course interface with the DOM model of the browser, typically using an AJAX library).
  • Pyjamas is a Python-to-Javascript compiler and AJAX-based Web Toolkit and Framework that allows users to write code in standard python that will be run in a web browser, after translation to javascript. pyjs - the compiler - can also be used as a stand-alone javascript compiler.

  • Py2Js is an unmaintained project that can still be downloaded here. It is purely a python-to-javascript compiler / translator.

  • PyPy is compiler technology that contains an alternative python interpreter front-end and also supports javascript as output on the back-end. Using Pypy/JS describes how to integrate with libraries such as mochikit.

Embedding Python inside Web Browsers

  • This section describes projects where the python interpreter itself can and has been embedded into the web browser. Instead of downloading the standard python executable and libraries, these projects come with the python runtime and libraries pre-embedded (and, as such, are typically very large downloads).
  • PyXPComExt has the full Python interpreter embedded. PyXPCOMExt is the interpreter as a XULRunner extension; PyDOM is a library that will almost certainly be needed, that allows you to manipulate the browser's DOM model using python. The API is (almost) identical to that of javascript.

Python wrappers around Web "Libraries" and Browser Technology

  • This section describes projects where you can (or have to) create your own web browser application in python. It includes web browser "engines" that have python interfaces to access, control and present web pages and web-relevant rich media content (such as Adobe Flash).
  • PyWebKitGtk - PyWebkitGtk is a python wrapper around Webkit that embeds the Webkit "engine" as a GTK widget. The standard version of pywebkitgtk is unable to provide access to the DOM model, treating pywebkit as a hands-off widget that can be used to write your own Web Browser (see demobrowser.py). However, a patch to webkit and a corresponding patch to pywebkitgtk will soon bring DOM model manipulation to python: see PyjamasDesktop for details.

  • PyWebkitQt4 is a python wrapper again around Webkit but this time as a Qt4 widget. Bindings to the DOM model have not been added to PyWebkitQt4, and so you can only use PyWekitQt4 to create your own web browser, rather than manipulate the DOM model content itself.

  • PyKDE - KDE contains python bindings to KHTMLPart (which is very similar to Webkit). This allows you to embed HTML into an application window. The Python bindings to the DOM model are slightly... obtuse. to say the least, and PyKHTML - PyKHTML makes them much more tolerable (see dom.py). However, there are limitations in PyKDE's DOM bindings (that many people will never encounter) that you should investigate thoroughly before utilising PyKDE for seriously heavy-duty DOM model manipulation.

  • Webkit with the ObjectiveC bindings (MacOSX users only). Webkit itself has ObjectiveC bindings, on MacOSX. MacOSX's ObjectiveC technology comes with automatic bindings to all major programming languages, including python. Consequently, you can directly manipulate the DOM model from python.

  • HulaHop provides python access to DOM model manipulation - via XUL / Gecko Interfaces. HulaHop is part of the OLPC Sugar Project, but is available stand-alone. It depends on pydom (part of XULrunner).

WebBrowserProgramming (last edited 2022-05-08 08:36:36 by Olivier Pirson)

Unable to edit the page? See the FrontPage for instructions.