【问题标题】:Python / cx_Freeze: askopenfile / askdirectory /// filedialogPython / cx_Freeze: askopenfile / askdirectory /// 文件对话框
【发布时间】:2014-10-10 10:41:32
【问题描述】:

我有一个问题。 我有一个程序 // 脚本,它运行良好,但是当我使用 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")])

感谢您的回答。

【问题讨论】:

  • 尝试专门做from tkinter import filedialog。看起来 cx_Freeze 由于某种原因无法复制它。
  • 谢谢,但我已经试过了。好吧,让我们再试一次。
  • OMG 现在可以工作了吗?!非常感谢

标签: python cx-freeze filedialog


【解决方案1】:

作为答案转发:

明确执行from tkinter import filedialog 可能会使其工作 - 看起来 cx_Freeze 没有复制 filedialog 模块。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-06-27
    • 2016-10-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多