About Charles Law

Charles started out in Systems Engineering, designing algorithms, but became a programmer once discovering Python's clean syntax. He has experience using many popular products and services in production environments including web2py, uwsgi, AWS, and OpenShift, as well as experience setting up front-ends in Javascript/Python. He tends to cover his experiences, and notes, from setting up servers, and talks about his experiments with different front-end tools.

Installing Pyjamas on Windows XP

Now for the good stuff! I followed a wiki post and got an old Pyjamas version working. The old Pyjamas version was missing some features, so I figured out a way to build the latest version from scratch. For documentation purposes, here are the steps I followed on Windows XP:

  1. Download and run a Python 2.6 installer (here’s a link to the latest: http://www.python.org/download/releases/2.6.6/)
  2. Install comtypes 0.6.1. (comtypes-0.6.1.win32.exe in http://sourceforge.net/projects/comtypes/files/comtypes/0.6.1/)
  3. Permanently update the path for Python (and Pyjamas while you’re at it)
    1. Go to System Properties through Control Panel
    2. Open the Advanced tab, then click on the Environmental Variables button
    3. Add the following to your “PATH” system variable: c:\python26;c:\Pyjamas\pyjs\bin; (the 2nd dir will exist after you install pyjamas)
  4. Install Git for Windows (If you have Git skip this step)
    1. Install msygit from http://code.google.com/p/msysgit/downloads/detail?name=Git- B
    2. Install TortisGit from http://code.google.com/p/tortoisegit/downloads/detail?name=TortoiseGit-
  5. Git the latest Pyjamas code.
    1. Create a directory C:\Pyjamas\
    2. Open an explorer window, and navigate to the C:\ drive.
    3. Right click on the Pyjamas directory and select Git Clone.
    4. Enter the URL: https://github.com/pyjs/pyjs.git git://pyjs.org/git/pyjamas.git
  6. Open a new command line (this has to be done after updating the path):
    1. > cd C:\Pyjamas\pyjs C:\Pyjamas\pyjamas
    2. > python bootstrap.py Note: The bootstrap won’t print anything to the screen, but it will create the bin directory (which was added to your path in step 3)
  7. Now test an application:
    1. > cd examples\helloworld
    2. > python __main__.py
    3. Use Firefox or IE and open output\Hello.html Note: Chome won’t load AJAX pages off your local machine for security reasons. You’ll have to upload it somewhere to see it in chrome. For more info see http://code.google.com/p/chromium/issues/detail?id=40787
  8. If you find anything different, update the wiki! Pyjamas Wiki

I ran through steps 1-4 once about 6 months ago. Since then I periodically rerun steps 5 and 6 to get the latest Pyjamas code.

One last note. I wouldn’t recommend pyjamas desktop on Windows if you’re doing Canvas apps. It will be good when a webkit pyjamas desktop version is out, but if you want pyjamas desktop, I’d go with Ubuntu 9.10. Because I have an Ubuntu box, I’ve never put in the time into figuring out how to get pyjamas desktop working on Windows with the latest Pyjamas code, but I do know others that are using it.

Thoughts on Pyjamas, Python and Web Apps

I was looking for a fun project to work on in my spare time, and while hanging out with my buddy Alex we started talking about coding and web apps. Even though I got an Electrical Engineering degree, I applied to college as a CS major and I still have an interest in CS and especially algorithms. What turned me off to CS was all the extra “fluff” you needed to write a real program. In school I’d always get templates that said “//Insert your algorithm here” and I never liked that.

That’s where Alex comes in. He was talking about how Python, and how clean and understandable the code is. I looked into it and there are a few features that really make coding simple. Python doesn’t require variable declarations, it includes lots of nice features like accessing the last element in an array using a [-1] index, the standard types have really uniform syntax, and the overall the Python syntax is clean. All those features made it simple to focus on algorithms, which is exactly what I was wanted.

What’s even better is Alex also talked about using a program called Pyjamas. With Pyjamas, you can write a web app in Python, and “compile” it to javascript so it runs in a standard browser. The idea sounded so clever. You could write an app using a language that lets you be very productive, and then compile and run your app in a regular browser.

I got a copy of Pyjamas (it’s open source code so it’s free at http://pyjs.org) and tried it out. After getting through the installation, which was really dated at the time (I’ll list all the steps I went through in my next post), I was writing really nice web apps. It was great! I started out creating a small game. I created a player which I could draw on the screen, and I could move around. I then created objects, like walls, that the player could interact with. Within a couple days I had a small game coded up using a language that was brand new to me.