0

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.

Cadda
  • 3
  • 1
  • You may intrested in a guid to [organize](https://stackoverflow.com/questions/63536505/how-do-i-organize-my-tkinter-appllication/63536506#63536506) your widgets – Thingamabobs Oct 31 '20 at 19:08

1 Answers1

1

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)
Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685