2014-10-10 42 views
0

我遇到了问题。 我有一个程序/ /脚本,完美的作品,但是当我编译它使用cx_Freeze,它不起作用:名称“filedialog”没有定义。 我必须以另一种方式导入它吗? 我的脚本部分:Python/cx_Freeze:askopenfile/askdirectory /// 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

尝试'从tkinter import filed filedialog'专门做'。它看起来像cx_Freeze由于某种原因无法复制它。 – 2014-10-10 18:56:20

+0

谢谢,但我已经试过了..好吧,让我们再试一次.. – ProgrammingDonkey 2014-10-11 15:13:09

+0

OMG Now It's working?!非常感谢你 – ProgrammingDonkey 2014-10-11 15:18:37

回答

0

转贴作为一个答案:

否则from tkinter import filedialog明确可能使它的工作 - 它看起来像cx_Freeze不复制FileDialog的模块。