Python, Tkinter. Как сделать так чтоб при наведении курсора на кнопку она как бы подсвечивалась?

Рейтинг: 0Ответов: 0Опубликовано: 14.07.2023
from tkinter import *
import tkinter.filedialog as fd

root = Tk()
root.geometry("700x400")
root.title('Мини редактор')
root["bg"] = '#333436'

text = Text(root, height=8, width=87, bg='#434547', fg='white', border=1, relief='flat')
text.place(x=0, y=0)

def open_file():
    path = fd.askopenfilename()
    print(path)
    if path != '':
        with open (path, 'r') as file:
            Text = file.read()
            text.insert(1.0, Text)

def save_file():
    path = fd.asksaveasfilename()
    Text = text.get("1.0", END)
    with open (path, 'w') as file:
        file.write(Text)

def clear_text():
    pass

btn_open = Button(root, text='   open file   ', command=open_file, bg='#495cc9', relief="groove", outline=None, fg='white', border=0)
btn_open.place(x=310, y= 200)

btn_save = Button(root, text='   save file    ', command=save_file, bg='#495cc9', relief="groove", outline=None, fg='white', border=0)
btn_save.place(x=310, y=230)

btn_clear = Button(root, text='   clear text  ', command=clear_text, bg='#495cc9', relief="groove", outline=None, fg='white', border=0)
btn_clear.place(x=310, y=260)

root.mainloop()

Вот есть код, хочу чтоб когда курсор был на кнопке она меняла свой цвет на противоположный, не при нажатие, а при наведении

Ответы

Ответов пока нет.