import tkinter
from tkinter import ttk
class GUI(tkinter.Tk):
def __init__(self):
tkinter.Tk.__init__(self)
self.geometry("500x500")
self.title("Red Frame Example")
self.grid_rowconfigure(0, weight=1)
self.grid_columnconfigure(0, weight=1)
red_frame_style = ttk.Style()
red_frame_style.configure("RedFrame.TFrame", background = "red")
red_frame = ttk.Frame(self, style="RedFrame.TFrame", width="250", height="250")
red_frame.grid_rowconfigure(0, weight=1)
red_frame.grid_columnconfigure(0, weight=1)
red_frame.grid(row=0, column=0, sticky="n")
button = tkinter.Button(red_frame, text='Stop', width=25, command=self.destroy)
button.grid(row = 1, column = 0)
gui = GUI()
gui.mainloop()
I am trying to get a 250 by 250 red frame to show up on my window in tkinter. Answers to this question suggested splitting a line like red_frame = tkinter.Frame(self, style="RedFrame.TFrame", width="250", height="250").grid(row=0, column=0, sticky="n")
into 2 different lines, which is what I tried to do in my code below, but the red frame still did not appear. What am I doing wrong here, and how can I fix it?