首先,需要一个给 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 ' )
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 )
2 font = pygame.font.Font( ' freesansbold.ttf ' , 40 )
最后,执行如下命令:
python setup.py py2exe
.........................................................