Button Tkinter xử lý sự kiện. Cấu hình thuộc tính: kiểu chữ, font-family, màu nền, màu chữ, cỡ chữ.
Đặt lại màu nền và thuộc tính khác bằng callback function.
Ví dụ
#Import tkinter library
from tkinter import *
from tkinter import ttk
#Tạo instance tkinter frame
win= Tk()
#Đặt geometry
win.geometry("750x250")
#Hàm thay đổi thuộc tính nút
def change_color():
btn.configure(bg="OrangeRed3", fg= "white")
#Tạo Label
Label(win, text= "Click the Button to reset the Color of the Button", font= ('Georgia 16 italic')).pack(pady=30)
#Tạo nút đóng cửa sổ
btn = Button(win, text ="RESET", command=change_color, font=('Georgia 11'))
btn.pack(side=TOP, ipady=5, ipadx=20)
win.mainloop()
Kết quả
Chạy mã hiển thị cửa sổ có nút và văn bản.

Bấm "RESET" thay đổi màu nền và màu chữ nút.
