你不能在ttk.Style() 中使用 bg 或 fg 短形式的 background 和 foreground 你已经使用完整的词 background 和 foreground 来配置样式。
tkinter.TclError: 未知选项“-bg”
您遇到的错误是因为您无法将 -bg 作为参数传递给ttk.Button()。要配置任何 ttk 小部件的样式,您必须使用 ttk.Style 及其受人尊敬的样式名称,例如 Button : "TButton", Label : "TLabel", Frame : "TFrame" 等等,请参阅documentation 的 Tk 主题小部件。
要为不同的按钮创建单独的样式,您可以创建自定义样式名称。
例如:
from tkinter import *
from tkinter import ttk
root = Tk()
button1_style = ttk.Style() # style for button1
# Configure the style of the button here (foreground, background, font, ..)
button1_style.configure('B1.TButton', foreground='red', background='blue')
button1 = ttk.Button(text='Deletar', style='B1.TButton')
button1.pack()
button2_style = ttk.Style() # style for button2
# Configure the style of the button here (foreground, background, font, ..)
button2_style.configure('B2.TButton', foreground='blue', background='red')
button2 = ttk.Button(text='Editar', style='B2.TButton')
button2.pack()
root.mainloop()