Reputation: 3
I'm just trying to get a red background for something i'm working on but for some odd reason (or maybe i'm being stupid) the frame just doesnt want to show up. When i run the code below all i get is this
from tkinter import *
master = Tk()
master.geometry("1200x600")
main_frame = Frame(
master,
bg = "#FF0000"
)
main_frame.pack()
if __name__ == '__main__':
mainloop()
When i try main_frame.pack(fill="both")
all i get to see is a single line of red pixels.
Does anyone know what is happening to my frames and how to possibly fix this?
Sorry if i'm asking something really stupid. I am just starting out with Python.
Upvotes: 0
Views: 99
Reputation: 385880
You haven't given the frame a size and there's nothing else in the frame, so it defaults to 1x1 pixel.
You can either give the frame a size, or use some of the pack
options to force it to fill the window.
main_frame.pack(fill="both", expand=True)
Upvotes: 1