简体   繁体   English

使用python 3.4用cx-freeze和tkinter冻结exe

[英]Freezing exe with cx-freeze and tkinter with python 3.4

I am having trouble getting cx-freeze to make my executable, which makes heavy use of tkinter. 我在使cx-freeze成为我的可执行文件方面遇到了麻烦,这使得tkinter大量使用。 My setup file code is as follows: 我的安装文件代码如下:

import sys
from cx_Freeze import setup, Executable

build_exe_options = {"packages":["tkinter"]}

base = None
if sys.platform == "win32":
    base = "Win32GUI"

setup(
    name = "distthis",
    version = "0.01",
    description = "Report Generator",
    options = {"build_exe": build_exe_options},
    executables = [Executable("distthis.py", base=base)]   
    )

When I try to build this from the command line (in the same directory) I can open the program, but it won't open a filedialog. 当我尝试从命令行(在同一目录中)构建它时,我可以打开该程序,但不会打开文件对话框。 I think the problem may be with tkinter. 我认为问题可能出在tkinter上。 Can anybody help? 有人可以帮忙吗?

Ok I found the answer here: Keep getting a 'filedialog' error after creating executable with cx_Freeze 好的,我在这里找到了答案: 使用cx_Freeze创建可执行文件后,始终出现“文件对话框”错误

Following the advice at the bottom of the page I changed the tkinter module imports to explicit ones and the problem was gone. 按照页面底部的建议,我将tkinter模块导入更改为显式导入,问题消失了。

If anybody knows why this strange behaviour happens I would love to know! 如果有人知道为什么会发生这种奇怪的行为,我很想知道!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM