1

I am making a python application that uses 4 ttk Frames within its main window. The first two frames should expand both vertically and horizontally to fill available space. Frames 3 and 4 should only expand horizontally and be a fixed height vertically. This is my code so far (minimum working example):

import tkinter as tk
from tkinter import ttk
tk_root = tk.Tk()
tk_root.geometry('500x500')
frame_1 = ttk.Frame(tk_root, padding=10, borderwidth=3, relief=tk.GROOVE)
frame_2 = ttk.Frame(tk_root, padding=10, borderwidth=3, relief=tk.GROOVE)
frame_3 = ttk.Frame(tk_root, padding=10, borderwidth=3, relief=tk.GROOVE, height=50)
frame_4 = ttk.Frame(tk_root, padding=10, borderwidth=3, relief=tk.GROOVE, height=50)
frame_1.pack(fill=tk.BOTH, expand=True)
frame_2.pack(fill=tk.BOTH, expand=True)
frame_3.pack(fill=tk.X, expand=True)
frame_4.pack(fill=tk.X, expand=True)
tk_root.mainloop()

When i run this the first two frames only expand to 50% of the window height and empty space is left around frames 3 and 4 (screenshot). I would like to have frames 3 and 4 be a constant height while frames 1 and 2 expand to fill all available space above frames 3 and 4.

Frames 1&2 filling the top half of the window, frames 3 and for with vertical space above and below them.

asked Oct 22, 2024 at 14:03
0

1 Answer 1

2

acw1668 gave the answer in a comment:

Remove expand=True for frame 3 and 4.

That did the trick.

Stephen Ostermiller
25.8k18 gold badges96 silver badges117 bronze badges
answered Oct 22, 2024 at 14:17
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.