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

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

并对 main.py 做简单的处理

1py2exe 转换 pytetris#font = pygame.font.Font(None, 40)
2py2exe 转换 pytetris 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/


相关文章:

  • 2021-09-27
  • 2022-03-05
  • 2021-11-12
  • 2021-08-09
猜你喜欢
  • 2022-12-23
  • 2021-11-08
  • 2022-12-23
  • 2021-06-13
  • 2022-12-23
  • 2021-06-03
  • 2021-07-07
相关资源
相似解决方案