冷冻Tkinter的应用我已冻结“字体没有定义”一TKinter的使用GUI的Python 3.4应用程式cx_Freeze和当我试图运行它,我提出以下错误:在由cx_Freeze
NameError: name 'font' is not defined.
当我从我的代码中删除了对字体的所有引用(例如,如果我没有在代码中的任何位置设置ttk标签字体),它工作得很好,并且EXE运行良好。我检查了由冻结脚本创建的library.zip压缩文件,它包含tkinter目录中的font.pyc文件。 这是文件看起来什么我setup.py,如:
import cx_Freeze
import sys
import tkinter
base = None
if sys.platform == 'win32':
base = "Win32GUI"
executables = [cx_Freeze.Executable("rocnikovka.py", base=base)]
cx_Freeze.setup(
name = "Number evolution",
options = {"build_exe": {"packages":["tkinter", "tkinter.font"], "includes": ["tkinter", "tkinter.font"]}},
version = "0.01",
description = "Rocnikovka",
executables = executables
)
任何帮助表示赞赏。
更新:我也尝试使用py2exe制作一个可执行文件,但最终获得了相同的结果。看起来像tkinter的问题,而不是与cx_Freeze。
更新#2:我进口的Tkinter和TTK在这样的脚本:
from tkinter import *
from tkinter import ttk
我在脚本中定义的几个字体,像这样的:
font_title = font.Font(family = "Exo 2", size = 20, weight = "bold")
然后我使用字体参数ttk.Label对象。
在IDLE中作为脚本运行时,这一切都很好。
尝试使用packages = []运行它,排除= [],cx-freeze发现tkinter与我一起使用python3.4 – timeyyy
感谢您的提示。不过,我一直在收到同样的错误。 –
毫米没有看到所有的代码很难尝试/多说。我猜这不是一个导入错误,因为你有一个名称错误而不是导入错误。除非你调用import tkinter.fontt,否则不会加载字体,代码是否可以像脚本一样运行? – timeyyy