我遇到了问题。 我有一个程序//脚本,它运行得很好,但是当我用cx_Freeze编译它时,它不起作用:名称“filedialog”没有定义。 我是否必须以另一种方式导入它? 我的剧本部分:
from tkinter import *
from shutil import *
import sys
import os
#Vars:
location = os.path.dirname(sys.argv[0])+"/"
if os.path.isfile(location+"filedic.txt"):
file = open(location+"filedic.txt","r").read()
else:
fiRoot = Tk()
fiRoot.withdraw()
file = str(filedialog.askdirectory())
我的设置脚本:
import sys
from cx_Freeze import setup, Executable
base = None
if sys.platform == "win32":
base = "Win32GUI"
setup(
name = "BlackChat",
version = "1.3",
description = "BlackChat was programmed by David Jandrey",
executables = [Executable("BlackChat.py", base = base,icon = "BlackChat.ico")])
感谢您的回答。
答案 0 :(得分:0)
重新作为答案:
明确地执行from tkinter import filedialog
可能会使其工作 - 看起来cx_Freeze没有复制filedialog模块。