将鼠标悬停在Tkinter中的按钮上时如何停止颜色变化?

时间:2020-09-18 09:44:08

标签: python-3.x tkinter

我不想将颜色更改为其他任何颜色。我希望将鼠标悬停在按钮上时不要将颜色更改为浅灰色。有什么办法可以在Tkinter中完成。

from tkinter import *

window = Tk()

button = Button(window, text="ok", fg='white', bg='black')

button.grid(row=0, column=0, padx=0, pady=0)

window.mainloop()

我顺便使用Ubuntu 20.04

1 个答案:

答案 0 :(得分:1)

您可以将activeforeground颜色设置为与fg颜色相同,将activebackground颜色设置为与bg颜色相同:

button = Button(window, text="ok", fg='white', bg='black',
                activeforeground='white', activebackground='black')
相关问题