Creating Python GUI Applications using XULRunner

Setting up a new Application

The directory layout of the application is described here: XulRunner Directory Layout. Following the steps below will maintain this layout structure so that the app can later be easily packaged and deployed. The Mac OS X layout is a little different, so ensure you follow the correctly marked platform sections in this guide.

Windows and Linux

  • Download and extract this pyxulrunner-template.zip for a starting template for your application. Mac OS X users should create and unpack the template into a Resources directory, as described in the link above. This will create a XULRunner application structure under the pyxpcom_gui_app directory.
    $ unzip pyxulrunner-template.zip
                        
  • Download the latest XulRunner 1.9 runtime build and extract it into your pyxpcom_gui_app directory:
    http://ftp.mozilla.org/pub/mozilla.org/xulrunner/nightly/latest-trunk/
    $ cd pyxpcom_gui_app
    $ unzip xulrunner-1.9.0.3pre.en-US.win32.zip
                        
  • Download the PythonExt extension (Mozilla 1.9 build):
    http://pyxpcomext.mozdev.org/downloads.html
    and extract the files over the top of XulRunner directory:
    $ cd xulrunner
    $ unzip pythonext-2.5.2.20080611-WINNT_x86-msvc.xpi
                        

Mac OS X

  • Create the application layout
    $ mkdir -p pyxpcom_gui.app/Contents
    $ mkdir pyxpcom_gui.app/Contents/Frameworks
    $ mkdir pyxpcom_gui.app/Contents/MacOS
                        
  • Download and extract this pyxulrunner-template.zip for a starting template for your application. Mac OS X users this will become your Resources directory, as described in the link above.
    $ cd pyxpcom_gui.app/Contents
    $ unzip pyxulrunner-template.zip
    $ mv pyxpcom_gui_app Resources
                        
  • Download the latest XulRunner 1.9 runtime build and install it onto your machine. By default, it will install into the /Library/Frameworks directory.
    http://ftp.mozilla.org/pub/mozilla.org/xulrunner/nightly/latest-trunk/
    After installing, copy the XULRunner files into your pyxpcom_gui.app directory:
    $ cd pyxpcom_gui.app/Contents
    $ cp -r /Library/Frameworks/XUL.framework/Versions/Current Frameworks/XUL.framework
                        
  • Download the PythonExt extension (Mozilla 1.9 build):
    http://pyxpcomext.mozdev.org/downloads.html
    and extract the files over the top of XulRunner directory:
    $ cd Frameworks/XUL.framework
    $ unzip pythonext-2.5.2.20080611-Darwin_universal.xpi
                        

We now have our sample application, as well as XulRunner (with Python integrated) which will run the application.