-
Notifications
You must be signed in to change notification settings - Fork 211
GettingStarted
Pyjamas 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.
Get the source either the git (preferred) or snapshot:
git clone https://github.com/pyjs/pyjs.git
Read the README and `INSTALL.txt <http://pyjamas.git.sourceforge.net/git/gitweb.cgi?p=pyjamas/pyjamas;a=blob_plain;f=INSTALL.txt;hb=HEAD`_, which comes basically down to:
cd <pyjamas directory> python bootstrap.py
Install Pyjamas:
sudo python run_bootstrap_first_then_pyjd_setup.py install
Install Pyjamas-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
If you run into problems installing Pyjamas (read: if you can't get the example applications running due to import errors) see the following articles:
- PyjamasUbuntu/#index5h2 (if you run Ubuntu the XULrunner/hulahop dependencies may be broken)
- PyjamasAndPyjamasDesktop (Pyjamas and Pyjamas-Desktop)
- InstallingPyjamasAndPyjamasDesktopForWindows (specific for Windows users)
- Pyjamas API documentation [TODO: Add link]
-
/examples/kitchensink/output/KitchenSink.html- UI Controls showcase -
/uiHierarchy.html- UI Hierarchy documentation -
/controls_tutorial.html- Writing Controls tutorial -
/controls_tutorial02.html- Event Handling tutorial - Pyjamas examples (show cases),
/showcase/Showcase.html//(defunct)// -
/book/output/Bookreader.html#Getting%20Started- Pyjamas Book -
/getting_started.html- Getting Started with Pyjamas (Tutorial)