cx_freeze:编译tkinter app没有启动

时间:2014-12-10 13:33:40

标签: python tkinter cx-freeze

这是我第一次使用cx_freeze,我真的需要帮助,我一直在寻找,但我找不到答案。

我在编译过程中没有任何错误,但可执行文件没有做任何事情。有人可以解释一下为什么吗?

这是我的项目结构:

应用

  • setup.py
  • application.py(从cell.py导入2个函数的Tkinter应用程序)
  • logo.jpg
  • 的favicon.ico
  • responsible.xls
  • 模块:
    • cell.py(所有工作都在此文件中完成)

我不知道在安装程序中包含文件cell.py的位置,现在它位于文件模块中。而且我不确定Tkinter是否应该包括或排除。

这是文件setup.py:

import sys
from cx_Freeze import setup, Executable


executables = [
        Executable("application.py")
]

buildOptions = dict(
        compressed = True,
        includes = ["sys","re","PIL","ttk","xlrd","xlutils","datetime","string","Tkinter"],
        include_files = ["responsible.xls","favicon.ico","logo.jpg"],
        excludes = []
        path = sys.path + ["modules"]
)

setup(
    name = "test",
    version = "1.1.1.0",
    description = "test",
    options = dict(build_exe = buildOptions),
    executables = executables
 )

1 个答案:

答案 0 :(得分:0)

使用include_files选项添加要包含的目录。 所以这部分代码应该是这样的:

buildOptions = dict(
        compressed = True,
        includes = ["sys","re","PIL","ttk","xlrd","xlutils","datetime","string","Tkinter"],
        include_files = ["responsible.xls","favicon.ico","logo.jpg", "modules"],
        excludes = []
        path = sys.path + ["modules"]
)