Reputation: 27822
How can I grow a widget vertically when I make the window larger?
I get a large grey unfilled area at the bottom:
How can I make the text
resize vertically? So I get something like this mockup:
I tried a bunch of of flags to both root
an text
, but nothing seems to do this :-/
Example code:
import tkinter as tk
root = tk.Tk()
root.columnconfigure(0, weight=1)
text = tk.Text(root, height=3)
entry = tk.Entry(root)
text.grid(row=1, column=0, sticky=tk.W + tk.E)
entry.grid(row=5, column=0, sticky=tk.W + tk.E)
root.mainloop()
Upvotes: 2
Views: 316
Reputation: 385980
Give the row that the widget is in a positive weight, and make sure the text widget has a sticky option for the north and south direction.
root.rowconfigure(1, weight=1)
# [...]
text.grid(row=1, column=0, sticky=tk.W + tk.E + tk.N + tk.S)
Upvotes: 4