引入

有时希望将 Python 写的图形程序生成可执行文件,可用 cx_Freeze 进行封装

Hello World 代码

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from cx_Freeze import setup, Executable

includes = ['tkinter']
includefiles = []
eggsacutibull = Executable(
    script = "helloWorld.py",
    initScript = None,
    base = 'Win32GUI',
    targetName = "helloWorld.exe",
    compress = True,
    copyDependentFiles = True,
    appendScriptToExe = False,
    appendScriptToLibrary = False,
    icon = None
    )

setup(
        name = "HelloWorld",
        version = "0.1",
        author = 'HouRong',
        description = "HelloWorld UI script",
        options = {"build_exe": {"includes":includes, "include_files": includefiles}},
        executables = [eggsacutibull]
        )