Python Tkinter Frame layout, weight, and resizing, Grid geometry manager Python Tkinter Frame layout, weight, and resizing, Grid geometry manager tkinter tkinter

Python Tkinter Frame layout, weight, and resizing, Grid geometry manager


For reference, below is the code after incorporating acw1668's suggestions.

The GUI now launches at expected size. There is sort of a secondary issue in that now the frame doesn't shrink below 500 px width (i.e., the Entry will not collapse back to natural size) though you can force the application window to be smaller. That's sort of a separate issue.

I can see there is some subtlety to this whole layout and resizing business and I've yet got a ways to go. ;)

Hopefully this question will have some pedagogic value to others following the same trail:

#!/usr/bin/env python3from tkinter import *from tkinter import ttkroot = Tk()root.title("Layout Problem")root.grid_columnconfigure(0, weight=1, minsize=500)root.grid_rowconfigure(0, weight=1, minsize=350)frame0 = ttk.Frame(root, padding=4)frame0.grid(column=0, row=0, sticky=(W, N, E, S))frame0.grid_columnconfigure(0, weight=1)frame0.grid_rowconfigure(0, weight=1)frame1 = ttk.Frame(frame0, padding=4)frame1.grid_columnconfigure(1, weight=1)frame1['borderwidth'] = 2frame1['relief'] = "ridge"frame1.grid(column=0, row=0, sticky=(W, N, E))# add widgets to 'frame1'ttk.Label(frame1, text="Label: ").grid(row=0, column=0, sticky=W)entryValue = StringVar()ttk.Entry(frame1, textvariable=entryValue)\    .grid(row=0, column=1, sticky=(W, E))entryValue.set("Entry")ttk.Button(frame1, text="Button")\    .grid(row=0, column=2, sticky=E)root.mainloop()