【问题标题】:App using TKinterModernThemes made with PyInstaller gives the error "invalid command name "set_theme""使用 PyInstaller 制作的 TKinterModernThemes 的应用程序给出错误 \"invalid command name \"set_theme\"\"
【发布时间】: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


【解决方案1】:

[已解决] 我在这里手动更改了我的路径 ThemedTKinterFrame。在里面,在第 64 行,像这样 self.root.tk.call("source", "/home/pi/.local/lib/python3.7/site-packages/TKinterModernThemes/themes/" + theme.lower() + " /" + theme.lower() + ".tcl")。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-06-16
    • 2022-06-28
    • 2023-02-12
    • 1970-01-01
    • 2019-01-18
    • 2021-12-12
    • 1970-01-01
    • 2016-06-16
    相关资源
    最近更新 更多