0
root.geometry("1000x750")
root.title("order recorder")
root.configure(background = "#399DAF")



def raise_frame(frame):
    frame.tkraise()


f1 = Frame(root)
f2 = Frame(root)
f3 = Frame(root)
f4 = Frame(root)

for frame in (f1, f2, f3, f4):
    frame.grid(row = 0,column = 0 , sticky = 'news')
    

Button(f1, text='Go to frame 2', command=lambda:raise_frame(f2)).pack()
Label(f1, text='FRAME 1').pack()

Label(f2, text='FRAME 2').pack()
Button(f2, text='Go to frame 3', command=lambda:raise_frame(f3)).pack()

Label(f3, text='FRAME 3').pack(side='left')
Button(f3, text='Go to frame 4', command=lambda:raise_frame(f4)).pack(side='left')

Label(f4, text='FRAME 4').pack()
Button(f4, text='Goto to frame 1', command=lambda:raise_frame(f1)).pack()

raise_frame(f1)








root.mainloop()

Not able to get the frames to fit to root They keep going to the edge or hiding , could you please post the code with explanation please I just started GUI in python

svyper
  • 17
  • 1
  • 3
  • Try adding `root.grid_columnconfigure(0, weight=1)` and `root.grid_rowconfigure(0, weight=1)` just after you create your `Tk()` – TheLizzard Apr 11 '21 at 11:59
  • [Please take a look at this](https://stackoverflow.com/questions/63536505/how-do-i-organize-my-tkinter-appllication/63536506#63536506) – Thingamabobs Apr 11 '21 at 12:07
  • @Atlas435 I don't think that is the problem here. OP's problem is that the frames don't expand to fill the whole window. OP is using `.grid` so they can put all of the frames in 1 stop and call `.tkraise()` on which ever frame they want to show. – TheLizzard Apr 11 '21 at 12:14
  • @TheLizzard where do you think I do adress the problem here? – Thingamabobs Apr 11 '21 at 12:18

1 Answers1

0

Rows and columns by default are only as big as the largest item they contain. You need to tell tkinter what to do with any space that is unallocated, such as when the window is larger than its contents.

Since you are using grid, you can configure tkinter to allocate all extra space to row 0 and column 0, causing each to expand to fit the window.

root.grid_rowconfigure(0, weight=1)
root.grid_columnconfigure(0, weight=1)
Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685