base
和
icon
是
options
属于
cx_Freeze.Executable
在你的代码中,它们没有被传递给它。他们需要加入
()
就像
"frame.py"
是否如此使用:
executables = cx_Freeze.Executable("frame.py", base=base, icon='ds.ico')
在里面
cx_Freeze.setup(options = ...
您首先添加了一个字典键
"packages"
作为字典键值的一部分
"build_exe"
但是突然你想要添加一个列表
include_files
而不是仍在字典中的键,它是值的一部分
“包”
到
“build\u exe”
钥匙这很难描述。无论如何
您的整个代码应该如下所示:
import cx_Freeze, sys
base = None
if sys.platform == 'Win32':
base = "Win32GUI"
executables = cx_Freeze.Executable("frame.py", base=base, icon='ds.ico')
cx_Freeze.setup(
name="cYou",
options = {"build_exe": {"packages":["tkinter"], "include_files":["ds.ico"]}},
version= "0.01",
description = "dasdasd",
executables = executables
)
下面是我对tkinter的使用。我只是把我的tkinter脚本
something.py
在此脚本旁边。然后我就回应它
something
. 为了包含图标文件,可能需要进行一些修改,例如:
from cx_Freeze import setup, Executable
import sys, os
fileName = input("What's the name of the py file to be converted to .exe?\n")
sys.argv.append('build')
os.environ['TCL_LIBRARY'] = r'C:\Users\username\AppData\Local\Programs\Python\Python36\tcl\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\Users\username\AppData\Local\Programs\Python\Python36\tcl\tk8.6'
base = None
if (sys.platform == "win32"):
base = "Win32GUI" # Tells the build script to hide the console.
elif (sys.platform == "win64"):
base = "Win64GUI" # Tells the build script to hide the console.
setup(
name='KutsalAklinNerde?',
version='0.1', #Further information about its version
description='Parse stuff', #It's description
executables=[Executable(fileName + ".py", base=base)])