Skip to content
This repository

Getting Started

Pyjs is slightly different from traditional Web development: it's more like Desktop application development. This guide should help you to get started quickly in developing your first application. You'll find references to API documentation, more tutorials and other guides in the Resources section below.

Just a quick getting started with Pyjs

Get the source either the git (preferred) or snapshot:

git clone https://github.com/pyjs/pyjs.git

Read the README and INSTALL.txt, which comes basically down to:

cd <pyjs directory>
python bootstrap.py

Install Pyjs:

sudo python run_bootstrap_first_then_setup.py install

Install Pyjs Desktop:

sudo python run_bootstrap_first_then_pyjd_setup.py install

Note

The latter scripts will create the pyjs and pyjd folders in /usr/local/lib/python2.6/dist-packages/ (system-wide installation) hence the need for running as root.

Go to the examples:

cd examples

Read the README, which will lead you to do:

python .

(or python __main__.py if you have python 2.5 or earlier)

If you've got apache running, add this to your default site config:

Alias /examples "REPLACE THIS/pyjamas/examples/"
<Directory "REPLACE THIS/pyjamas/examples/">
    Options Indexes MultiViews FollowSymLinks +ExecCGI
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
    AddHandler cgi-script .py
</Directory>

and point your browser to http://localhost/examples/

Checkout the /examples/helloworld/ helloworld example

Look at it /examples/helloworld/output/Hello.html in the browser

Look at the source code:

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

def greet(sender):
    Window.alert("Hello, AJAX!")

class Hello:
    def onModuleLoad(self):
        b = Button("Click me", greet)
        RootPanel().add(b)

Play with the code on your local machine, use the build.sh script (or ../../bin/pyjsbuild <ModuleName>) to compile your python code to HTML and JavaScript, see what happens.

  • Look at some more examples, in the /examples/ directory
  • Look at some more examples
  • Did I say 'Look at some more examples'?
  • Build your own from a copy from helloworld

Troubleshooting

If you run into problems installing Pyjs (read: if you can't get the example applications running due to import errors) see the following articles:

Learning Resources

!tag howto tutorial

Something went wrong with that request. Please try again.