首页 > 解决方案 > 为 Tkinter 安装 ttk 主题

问题描述

我目前正在尝试使我使用 tkinter 构建的一些应用程序看起来更好。我读到您可以使用 ttk 更改 tkinter 的主题,并使其与内置主题一起使用。

import tkinter.ttk as ttk
from tkinter import *
import ttkthemes

root = Tk()
root.geometry('400x200')

ttk.Style().theme_use('alt')

Button1 =ttk.Button(text="Test").pack()
root.mainloop()

但是由于内置的​​有点过时了,我开始尝试从这个列表中安装外部的:https ://wiki.tcl-lang.org/page/List+of+ttk+Themes 。我尝试pip install ttkthemes并希望让“Adapta”主题发挥作用(https://ttkthemes.readthedocs.io/en/latest/themes.html)。我尝试导入 ttkthemes,但无法正常工作。Python 执行时找不到主题_tkinter.TclError: can't find package ttk::theme::adapta。那么如何将这些外部主题导入python?

标签: pythontkinterthemes

解决方案


推荐阅读