0

I'm trying to learn how layouts work in tkinter but i cant figure it out for the life of me. I'm simply trying to organize widgets within a frame. The problem is when I try to put a label in the frame it ignores the height, width and background I set for the frame. What am I doing wrong? Heres the code:

 from tkinter import *

 root=Tk()
 root.title("testing")


 frame=Frame(width=500, height=500, bg="darkblue")
 frame.pack()

 label=Label(frame, text="test")
 label.grid(row=0,column=0)

 root.mainloop()
  • 1
    tkinter will autosize the window dynamically, I believe in your case you want to size the root window, then size your individual items to fill as you wish, a detailed answer was written here. https://stackoverflow.com/questions/34276663/tkinter-gui-layout-using-frames-and-grid/34277295#34277295 – John T Jan 16 '20 at 20:51
  • Change `frame.pack()` to `frame.grid()` and `Label(frame,text="test")`to`Label(root,text="test")` would solve your issue. – DaniyalAhmadSE Jan 17 '20 at 14:23

0 Answers0