Tkinter复选框单击动画颜色更改



我有一个复选框,Tkinter窗口和复选框的背景是白色的:

from tkinter import *
root =Tk()
root.config(bg='white')
x = IntVar(value=0)
checkbox = Checkbutton(variable=x, text='check me')
checkbox.config(bg='white')
checkbox.pack()
mainloop()

当你点击它时,它会变成灰色。我该怎么做才能让它不变成灰色(一直变成白色(?感谢:D

我认为您希望像这样使用activebackground="white"

from tkinter import *
root = Tk()
root.config(bg="white")
x = IntVar(master=root, value=0)
checkbox = Checkbutton(root, variable=x, text="check me",
activebackground="white")
checkbox.config(bg="white")
checkbox.pack()
root.mainloop()

最新更新