Apr-25-2019, 02:13 PM
I want to change the background of a frame using four colour buttons placed at four corners of the frame.
I was trying by adding only one button in the frame and changing the color when button is pressed but its not changing the color when the button is in the frame and works when the button is in the window.
I was trying by adding only one button in the frame and changing the color when button is pressed but its not changing the color when the button is in the frame and works when the button is in the window.
import tkinter as tk root = tk.Tk() root.geometry("100x100") frame = tk.Frame(root, height=100, width=100) def change_bg(): frame.config(background='red') button = tk.Button(frame, text="Paint",command=change_bg) button.pack() frame.pack() root.mainloop()