I begin with Tkinter and I try to understand the different geometry package managers. I found something weird and I would like a explanation.
I test two pieces of code :
import tkinter as tk
fen = tk.Tk()
fr1 = tk.Frame(fen).grid(row=0,column=0)
fr2 = tk.Frame(fen).grid(row=0,column=1)
txt1 = tk.Label(fr1, text="txt1").pack(side="top")
tk.Frame(fr1,bg="blue",height=5).pack(side="bottom",fill="x")
txt2 = tk.Label(fr2, text="txt2").pack(side="top")
tk.Frame(fr2,bg="red",height=5).pack(side="bottom",fill="x")
and
import tkinter as tk
fen = tk.Tk()
fr1 = tk.Frame(fen)
fr2 = tk.Frame(fen)
txt1 = tk.Label(fr1, text="txt1").pack(side="top")
tk.Frame(fr1,bg="blue",height=5).pack(side="bottom",fill="x")
txt2 = tk.Label(fr2, text="txt2").pack(side="top")
tk.Frame(fr2,bg="red",height=5).pack(side="bottom",fill="x")
fr1.grid(row=0,column=0)
fr2.grid(row=0,column=1)
Just the position of the call to the grid is different.
The first one sends me a geometry error :
"cannot use geometry manager pack inside . which already has slaves managed by grid"
and the second one works.
Why there is this difference in behaviour?