Pyjamas is a port of Google’s Web Toolkit to Python

22 Apr

Pyjamas is a port of Google’s Web Toolkit to Python (GWT is a Java to AJAX compiler and Web-based Applications Widget set, where Pyjamas is a Python to AJAX compiler). More Info


Like GWT, pyjamas involves the translation of the application and libraries (including UI widgets and DOM classes) to Javascript and the packaging up of that Javascript code.

There are two core developer tools included with pyjamas.  pyjs[1] translates Python code to Javascript by walking the Python abstract syntax tree and generating Javascript.

In many cases, built-in Python types require a custom Javascript implementation.  For example, even though Python lists are similar to Javascript arrays, Python lists are converted to custom objects that implement methods such as append.  These custom objects, required for translation by pyjs, are defined in a library called pyjslib.[2]

Like GWT, pyjamas comes with a set of UI widgets as well as a library for DOM manipulation.[3] These libraries are written in Python but are, like everything else, translated to Javascript for deployment.

The overall translation of individual components is managed by build[4] which also creates the necessary boilerplate code.  The result is a set of.html and .js files that can be served up by a Web server.

There are other components planned which have not been covered here such as server-side code for communication in client-server applications. The examples do however contain JSONRPC server-side source code (in cgi python, and php) which give an idea of what’s involved.

The Pyjamas Widget set, documented here is exceptionally comprehensive and yet is easy to use, providing:

If the available widgets and the addon contributed widgets are not enough, then there is a simple tutorial on how to create your own widget. The underlying basis of all widgets is to encapsulate manipulation of an HTML DOM model, representing the screen.

Additional features, thanks to the underlying use of webkit, include:

  • Full CSS Stylesheet functionality, both local, remote and direct and simple API manipulation.
  • Option of executing javascript, for full and complete manipulation of the application.
  • Loading of complete HTML Pages, both local and remote; full URL support.
  • Plugin support for multimedia plugins such as Flash (obsoleting the need for gtk-mozplugin)
  • Access to XML, XSLT and AJAX.
  • (Future: full SVG Canvas support, like HippoCanvas)


1 Comment

Posted by on April 22, 2009 in Web


Tags: , ,

One response to “Pyjamas is a port of Google’s Web Toolkit to Python

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: