Using the example from this SO question with a couple slight modifications to the size: What does 'weight' do in tkinter?
import tkinter as tk
root = tk.Tk()
root.geometry("400x200")
f1 = tk.Frame(root, background="bisque, height=200)
f2 = tk.Frame(root, background="pink", height=200)
f1.grid(row=0, column=0, sticky="nsew")
f2.grid(row=0, column=1, sticky="nsew")
root.grid_columnconfigure(0, weight=4)
root.grid_columnconfigure(1, weight=1)
root.mainloop()
This produces the expected output of this:
column f2 takes up a quarter of the screen
If I then add a label to column F2 that is not wider than the already existing column, f2 gets wider anyway. The more characters the worse it gets:
import tkinter as tk
root = tk.Tk()
root.geometry("400x200")
f1 = tk.Frame(root, background="bisque", height=200)
f2 = tk.Frame(root, background="pink", height=200)
f1.grid(row=0, column=0, sticky="nsew")
f2.grid(row=0, column=1, sticky="nsew")
root.grid_columnconfigure(0, weight=4)
root.grid_columnconfigure(1, weight=1)
label_example = tk.Label(f2, font=("Impact", 20, "italic", "bold"), text="A", fg='dark orange', bg='black')
label_example.pack()
root.mainloop()
column f2 is now taking more than a quarter
I don't understand why column f2 is getting wider when I add this label to it. This happens even without setting the font size. It seems like there is padding going on with the label OR that adding things to frames somehow affects the weight property. I have been stumped on this for quite a while now. I understand I can use grid_propagate to disable this, but that seems like a hacky way to fix this. I want to learn /why/ it is happening.
What I need is for one column to take up 3/4 of the screen with the other taking 1/4. What am I not understanding about column width weights? Thanks