py2exe 转换 pytetris

首先,需要一个给 py2exe 使用的 python 脚本,我命名为 setup.py,内容如下:

1 from  distutils.core  import  setup
2 import  glob, shutil
3 import  py2exe
4 setup(windows = [ " main.py " ])
5 shutil.copytree( ' SFX ' ' dist/SFX ' )
6 shutil.copytree( ' Image ' ' dist/Image ' )
7 shutil.copyfile( ' C:/Python25/Lib/site-packages/pygame/freesansbold.ttf ' ' dist/freesansbold.ttf ' )

并对 main.py 做简单的处理

1 # font = pygame.font.Font(None, 40)
2  font  =  pygame.font.Font( ' freesansbold.ttf ' 40 )

最后,执行如下命令:

python setup.py py2exe

.........................................................
关于 py2exe
简介
py2exe is a
Python Distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation.
下载
http://sourceforge.net/projects/py2exe/

你可能感兴趣的:(windows,python,image,exe,import,extension)