【发布时间】:2022-08-05 18:24:53
【问题描述】:
我一直在尝试使用 tkinter、TKinterModernThemes 制作应用程序,并使用 PyInstaller 将其转换为可执行文件,但我没有运气。每次我尝试使用任何使用 ttk 主题的模块时,都会遇到某种错误。我决定使用 TKinterModernThemes 模块。使用 PyInstaller 制作 exe 会出现以下错误:
File \"TKinterModernThemes\\__init__.py\", line 66, in __init__
_tkinter.TclError: invalid command name \"set_theme\"
我尝试将 tkinter 和 TKinterModernThemes 作为隐藏导入包含在 PyInstaller 中,尝试使用和不使用 --onefile,并改用 Nuitka(同样的错误)。任何帮助都会很棒。
-
为了提供帮助,您的问题中需要包含更多信息,例如,目录结构、您尝试编译的代码示例、您输入终端的命令、pyinstaller 的规范文件输出,收到的任何错误消息。
-
它在使用 PyInstaller 编译之前运行吗?我已经用 pip 安装了TKinterModernThemes 并尝试运行其中一个示例,我也得到了
_tkinter.TclError: invalid command name \"set_theme\"。 -
在查看代码后,似乎我得到了错误,因为模块未能加载与主题对应的 tcl 模块,因此该模块中定义的 set_theme 命令失败。问题是在
ThemedTKinterFrame.__init__(在TKinterModernThemes/__init__.py)中定义路径的方式,我不得不在路径第66行周围添加os.path.abspath(...)。
标签: python tkinter pyinstaller ttk