Pyjs | |
Logo Size: | 192px |
Logo Alt: | Logo of the Pyjs project (aka Pyjamas), after forking off in 2012. |
Author: | James Tauber, Google |
Developer: | Luke Leighton, Anthony C Risinger, Kees Bos |
Programming Language: | Python, JavaScript |
Operating System: | Windows, OS X, Linux |
Language: | Python |
Genre: | Ajax framework, Desktop and Web Widget toolkit, Compiler, Widget set |
License: | Apache License 2.0 |
Pyjs (formerly Pyjamas before May 2012[1]), is a rich web application framework for developing client-side web and desktop applications in Python. The resulting applications can be run in a web browser or as standalone desktop applications.
It contains a stand-alone Python-to-JavaScript compiler, an Ajax framework and widget toolkit, and through use of these components, developers can write comprehensive applications, to run in all major web browsers, without writing any JavaScript. Pyjs is a port of Google Web Toolkit (GWT) from Java to Python.[2]
Using pyjs, developers can write web applications in Python instead of JavaScript. The application is compiled to JavaScript. Also included is an Ajax library and widget set[3] that provides access to the Document Object Model (DOM) of modern JavaScript-capable web browsers. The Ajax library and the widget set library are a hybrid mix of Python and JavaScript. Just as with Google Web Toolkit, pyjs is not its libraries, and neither is it just another Ajax framework. Ajax frameworks are strictly limited to providing pre-prepared specific functionality, written almost exclusively in tailor-made JavaScript. Both GWT and pyjs, being JavaScript compilers, allow the developer to work in the language with which they are familiar (Java or Python, respectively), to write their own custom widgets, either entirely from scratch or based on the existing available widgets, yet still target the full range of modern browsers. So, far from presenting web developers with a ready-made Ajax framework, pyjs gives you the freedom to create your own.
The pyjs compiler is written in the programming language Python, and uses it to compile its input into JavaScript, walking the abstract syntax tree of the program being compiled. Although the compiler is stand-alone, the primary use of pyjs is for web development, so there is additional infrastructure for building web applications.
The DOM.py model library is an abstraction layer — a thin layer of Python on top of JavaScript code snippets — use of which provides access to the full Document Object Model of the target browser platform. As with any compiler, the JavaScript snippets are treated as inline assembler.
Furthermore, on top of the DOM.py model library is an additional abstraction layer, ui.py, which provides the most useful layer to web developers: a full suite of widgets with which desktop application developers will be familiar. At present, the list of available widgets is a mixture of the complete set of widgets that were available in Google Web Toolkit 1.2, along with a few more that have been forward-ported from GWT 1.5.
The major Pyjs components include:
The widget set library[3] that comes with pyjs is so similar to PyQt and PyGTK that a port of pyjs was made to run pyjs applications on the desktop, called pyjs Desktop (formerly PyjamasDesktop[6] before May 2012 and originally hosted separately prior to version 0.6[7]). The project uses Webkit, XULRunner or MSHTML as the underlying technology, and it is through these browser engines that pyjs manipulates the DOM model of the application. Together pyjs and pyjs Desktop allow writing cross-platform, cross-desktop, cross-browser and cross-widget applications that run on the web and on the desktop.[8] [9]