I am trying to create a Tkinter layout that has labels and input fields vertically aligned in several LabelFrame blocks.
Here is some simplified code:
#!/usr/bin/python from Tkinter import * win = Frame() win.grid(sticky=N+S+E+W) frame_a = LabelFrame(win, text='Top frame', padx=5, pady=5) frame_b = LabelFrame(win, text='Bottom frame', padx=5, pady=5) frame_a.grid(sticky=E+W) frame_b.grid(sticky=E+W) for frame in frame_a, frame_b: for col in 0, 1, 2: frame.columnconfigure(col, weight=1) Label(win, text='Hi').grid(in_=frame_a, sticky=W) Label(win, text='Longer label, shorter box').grid(in_=frame_b, sticky=W) Entry(win).grid(in_=frame_a, row=0, column=1, sticky=W) Entry(win, width=5).grid(in_=frame_b, row=0, column=1, sticky=W) win.mainloop()
In the above code, a window is created that looks like this:

While I'm looking to find a way to align the margins so that the window looks bigger (thanks to MS Paint):

I played with in_ arguments before grid() , but didn't achieve very much, and I can't think of anything else to experiment with.
source share