TkInter: Can't fill a Frame with another widget
<p>First time with TkInter. According to what I've read, you can use Frame widgets to hold other widgets. So, I laid down some preview Frames as such:</p>

<pre><code>import tkinter as tk


root = tk.Tk()

TextFrame = tk.Frame(root, width=200, height=600, bg="red")
TextFrame.pack(side="left")

ListFrame = tk.Frame(root, width=800, height=600, bg="blue")
ListFrame.pack(side="right")
</code></pre>

<p>However, when I add a widget and tell it to fill the Frame, it simply replaces the frame instead of expanding to fill the area. Test code used:</p>

<pre><code>ListBox = tk.Listbox(ListFrame, selectmode="single", bg="#545454", fg="#d9d9d9")
for X in range(20):
    ListBox.insert('end', X)
ListBox.pack(fill='both', expand=True)
</code></pre>

<p>The same test code expands properly if I set the parent to the main 'root' object. Example:</p>

<pre><code>import tkinter as tk


root = tk.Tk()
root.geometry("1000x600")

ListBox = tk.Listbox(root, selectmode="single", bg="#545454", fg="#d9d9d9")
for X in range(20):
    ListBox.insert('end', X)
ListBox.pack(side="right", fill='both', expand=True)

TextBox = tk.Message(root, text="A bunch of text", width=100)
TextBox.pack(side="left", fill="y")
</code></pre>

<p>Am I doing something wrong, here?</p>

<p>Frames are like elastics, they grip their content.
You could add:</p>

<pre><code>ListFrame.pack_propagate(False)
</code></pre>

<p>to switch off that behavior</p>

python tkinter