Python 按下按钮时如何更改按钮颜色?

Python 按下按钮时如何更改按钮颜色?,python,button,tkinter,Python,Button,Tkinter,我有一个橙色背景的按钮。但按下按钮后,颜色就不一样了。它将更改为默认颜色。松开按钮后,我得到了相同的颜色。按下按钮时,是否可以更改按钮的颜色 我的代码是: b = Button(frame1, text='Quit', command=quit_func) b.grid(row=6,column=4,pady=5,padx=10) b.config( background="darkorange1", foreground="white") 按钮小部件将activeba

我有一个橙色背景的按钮。但按下按钮后,颜色就不一样了。它将更改为默认颜色。松开按钮后,我得到了相同的颜色。按下按钮时,是否可以更改按钮的颜色

我的代码是:

b = Button(frame1, text='Quit', command=quit_func)
b.grid(row=6,column=4,pady=5,padx=10)            
b.config( background="darkorange1", foreground="white")

按钮
小部件将
activebackground
activeforeground
作为参数

from tkinter import *

root = Tk()

b = Button(root, text='Quit', command="")
b.grid(row=6,column=4,pady=5,padx=10)
b.config(background="darkorange1", foreground="white",
         activebackground="darkorange1", activeforeground="white")

root.mainloop()
对于按钮小部件选项的完整列表,您可以阅读它