【问题标题】:tkinter ttk theme: _tkinter.TclError: image file format "svg" is not supportedtkinter ttk 主题:_tkinter.TclError:不支持图像文件格式“svg”
【发布时间】:2021-10-08 07:09:09
【问题描述】:

我试用了this ttk theme,它使用了svg 图像。但它说不支持图像文件格式svg

在这一行:

root.tk.call('source','./DATA/themes/sun-valley-dark.tcl')

出现此错误:

Traceback (most recent call last):
  File "guitesting.py", line 141, in <module>
    root.tk.call('source','./DATA/themes/sun-valley-dark.tcl')
_tkinter.TclError: image file format "svg" is not supported

有用的信息:

OS: Windows 7
Python: Python 3.8.10
Architecture: x86 (32-bit)
Tkinter version: 8.6

【问题讨论】:

  • 正如错误所说,tkinter 不支持svg 格式。
  • 那么我该如何使用这个主题?
  • 我不知道你是从哪里得到这个主题的,但是当我搜索它时,我找到了github.com/rdbende/Sun-Valley-ttk-theme,它使用 PNG 文件并且对我来说很好。
  • 那么我可以通过任何方式使用这个主题吗?

标签: python tkinter svg themes ttk


【解决方案1】:

通过 pip 安装 tksvg:python -m pip install tksvg

在文件顶部添加

import tksvg

tksvg.load(root)
root.tk.call('source','./DATA/themes/sun-valley-dark.tcl')

【讨论】:

    【解决方案2】:

    要使用主题,我必须通过 pip 安装 tksvgpython -m pip install tksvg

    **我通过电子邮件得到了@rdbende 的答复

    【讨论】:

      猜你喜欢
      • 2018-01-26
      • 1970-01-01
      • 2023-04-02
      • 2016-02-26
      • 1970-01-01
      • 2021-11-18
      • 2021-12-20
      • 1970-01-01
      • 2016-02-20
      相关资源
      最近更新 更多