Jul-28-2023, 02:31 PM
If you want to control the appearance of a widget in it's disabled state, configure the widget when you create it, or use a style.
import tkinter as tk def toggle_state(widget): state = tk.DISABLED if widget["state"] != tk.DISABLED else tk.NORMAL widget.configure(state=state) root = tk.Tk() entry = tk.Entry(root, font=("Arial", 12), bg='lightblue') entry.configure(disabledbackground=entry["bg"], disabledforeground=entry["fg"]) # Look same when disabled. entry.pack(side=tk.TOP, padx=10, pady=5) button = tk.Button(root, text="Toggle State", font=("Arial", 24), command=lambda: toggle_state(entry)) button.pack(side=tk.TOP, padx=10, pady=5) root.mainloop()