Home  About  Old News  Links 
 Become The Media A "100% Vegan" Production 
. : py2exe how-to : .

. : Python : .
» pygtk / py2exe 0.4.x how-to
  How-to build standalone windows executables for GTK+2.0 using py2exe 0.4.x
» pygtk / py2exe 0.5.x how-to
  How-to build standalone windows executables for GTK+ 2.2 or 2.4 using py2exe 0.5.x
. : Overview : .
Here's a How-To on generating stand-alone executables for pygtk programs using py2exe 0.4.x  Any comments, please email me: py2exe at anti-particle dot com
. : Initial Installation (Windows OS): .
1) Install the latest version of python. You may need to add the install location to your PATH environment variable...
  e.g. c:\python23
2) Install the latest version of GTK for windows. Add the locations of the bin and lib folders to your PATH environment variable...
  e.g. c:\Program Files\Common Files\GTK\2.0\bin
  e.g. c:\Program Files\Common Files\GTK\2.0\lib
3) Install the latest version of pygtk for windows.
4) Install py2exe.
5) Install the installer! Inno Setup.
6) A useful extra is ISTool which can edit the scripts Inno Setup produces.
. : Configure your project : .
The code where gtk and pygtk get imported into your project should look something like:
import pygtk
#this is needed for py2exe
if sys.platform == 'win32':
    #win32 platform, add the "lib" folder to the system path
    os.environ['PATH'] += ";lib;"
    #not win32, ensure version 2.0 of pygtk is imported
import gtk
import gobject
assert gtk.pygtk_version >= (1,99,16), 'pygtk should be >= 1.99.16'
. : Configure py2exe for your project : .
1) Build a file. Here is one I used for The Pycadia Project:
from distutils.core import setup
import py2exe
import glob

                ("pixmaps", glob.glob("pixmaps/*.png")),
                ("sounds", glob.glob("sounds/*.wav")),
                ("glade", glob.glob("glade/*.*"))
2) Build a setup.cfg file. Here is an example:
version-legalcopyright=2003 Fingal McFungal
version-filedescription=The Project Title
. : Build the executable : .
From a command prompt in your project_name folder, run:
python py2exe --force --windows
This should create a dist\project_name folder in your project folder.
. : Supplementary files : .
Copy the GTK subfolders etc and lib to your dist\project_name folder.
copy c:\Program Files\Common Files\GTK\2.0\etc dist\project_name
copy c:\Program Files\Common Files\GTK\2.0\lib dist\project_name
At this point you should have something that works. Try it out by copying the dist\project_name folder to a clean PC and giving it a go...
. : Build the installer : .
Watch this space...
. : Last update: Friday, 14-Jun-2013 16:11:26 BST : .
Initial Design: Copyleft © 02001 Jaden
The Rest: Copyleft © 02002-02006 Andy Balcombe