我正在尝试使用ttkthemes中的某些主题来为tkinter
GUI设置样式。我找到了此代码:
from ttkthemes import ThemedStyle
import tkinter as tk
from tkinter import ttk
app = tk.Tk()
app.title('App')
style = ThemedStyle(app)
style.set_theme("black")
tktext = tk.Label(app, text=" tk Label")
tktext.pack()
tkbutton = tk.Button(app, text="tk Button")
tkbutton.pack()
text = ttk.Label(app, text=" ttk Label")
text.pack()
button = ttk.Button(app, text="ttk Button")
button.pack()
app.geometry('200x200')
app.mainloop()
在本主题中:Python - How do I add a theme from ttkthemes package to a guizero application?
但是我有一个问题,那就是当我运行程序时,主题无法覆盖整个根窗口,只有ttk
中的按钮或标签都采用了主题(使用Windows10)。我尝试了其他方法代码和每次相同的问题。有什么问题吗?ttktheme
主题仅适用于ttk模块中的小部件。对于不在ttk中的小部件(例如文本小部件),您必须单独配置它们。