所以我尝试使用以下代码将简单样式应用于labelframe小部件:
import sys
if sys.version_info[0] == 2: # Just checking your Python version to import Tkinter properly.
import Tkinter as tk
import ttk as ttk
else:
import tkinter as tk
from tkinter.ttk import ttk as ttk
root = tk.Tk()
bls = ttk.Style()
bls.configure('Black.TLabelFrame', background="#222222")
dayframe = ttk.Labelframe(root, style='Black.TLabelFrame', height=200, width=150, relief=tk.SUNKEN,
text="Hello")
dayframe.grid(row=1, column=1, padx=5)
root.mainloop()
但是当我运行此代码时,我收到错误消息:
TclError:找不到布局Black.TLabelFrame
我不明白我做错了什么......
答案 0 :(得分:6)
使用较低Black.TLabelframe
f