import tkinter as tk
root = tk.Tk()
def change_button_color():
global button_color, button_bg_color
if button_color == "red":
button_color = "blue"
button_bg_color = "yellow"
else:
button_color = "red"
button_bg_color = "green"
button.config(fg=button_color, bg=button_bg_color)
button_color = "red"
button_bg_color = "green"
button = tk.Button(root, text="Нажми меня", command=change_button_color)
button.pack()
root.mainloop()