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.
Before you continue, be sure that you have these tools installed on your machine:
python (http://www.python.org/) pip (https://pypi.python.org/pypi)
Note: If you get a "permission denied" error when using pip or setup.py, you may add the --user flag to install to a location in your home directory, which should resolve any permissions issues. Doing this, you may need to add this location to your PATH and PYTHONPATH. Alternatively, you can run this with 'sudo'.
If you want Pyjs only for your apps use it, simply do this:
pip install git+https://github.com/pyjs/pyjs.git#egg=pyjs
This will install Pjs, Pyjs-Tools and all dependencies.
Get the source from the git:
git clone https://github.com/pyjs/pyjs.git
Change into the pyjs root directory:
cd <pyjs root>
Install Pyjs, Pyjs-Tools, and all dependencies:
python setup.py install
You are now ready to use Pyjs. Once it is installed, you can import Pyjs to your python script using:
pyjscompile pyjsbuild pyjampiler
Checkout and build the
helloworld example (it is in repository folder):
cd examples/helloworld pyjsbuild hello.py
./output folder containing all files you need to move to your webspace later. Of course you can test locally, too.
For test locally, just look
/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)
If you've got apache running, add this to your default site config:
Alias /examples "REPLACE THIS/pyjs/examples/" <Directory "REPLACE THIS/pyjs/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/
Play with other examples on your local machine, use
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:
/controls_tutorial.html- Writing Controls tutorial
/controls_tutorial02.html- Event Handling tutorial
/getting_started.html- Getting Started with Pyjs (Tutorial)