Google Web Toolkit and Python's Pyjamas

I was curious about the Google Web Toolkit and the Google App Engine for longtime, but never get the opportunity to make a try.

Surfing the web, looking for Python's things, I found Pyjamas, a Python-based Web Application Development Framework.

Pyjamas is no more than a compiler that compile Python code into HTML and javascript files. The original Python code must create the DOM tree using Pyjamas's widgets (in fact the sames as the one used by Google Web Toolkit, here is the link) and modify it (the DOM tree) depending user actions. The resulting javascript does the job inside the web browser, the Python code is never run. Until here no web server are required !

This is how the beamMail mail client looks like (awesome isn't it ?):

Because javascript cannot access local computer files or even connect to the network using something else than HTTP request (to do AJAX for example), Pyjamas code has the same restriction. You must load and save data using the XMLHttpRequest object via a Web server. This web server can be written in Python (or not).

This was the opportunity I was looking for to try the Google Web Toolkit. The GWT does the same has Pyjamas but use Java instead of Python and provide all the support inside the Eclipse IDE to write the server part at the same time. I'm impressed about how the environment is well integrated and how it's easy to debug the java code thanks to a plugins inside Firefox.

Pyjamas and GWT share the same widget set, but Pyjamas don't have such environment nor Firefox plugins to debug the Python code. Instead Pyjamas provides real widgets like QT, GTK or wxWidget, to run the application without any web browser as any graphical application. This time the Python code is running for real and can be debugged as any Python application.

Finally the server part of the GWT application can be compiled and uploaded as a Google App Engine. Google App Engine also support Python server.

To have an idea of what I'm speaking about, here is the Hello world sample. The application create a button that display "Hello world" when clicked.

from pyjamas import Window
from pyjamas.ui import RootPanel, Button

def greet(sender):
    Window.alert("Hello world")

b = Button("Click me", greet)
The Java equivalent is a lot bigger because of the need of the variable declaration.

Add new comment