I am using Tkinter and I want my elements to resize when the window resizes (only horizontally)
I tried sticking to W+E
but apparently this only works when the window is created but not when it's resized.
Minimal example:
from tkinter import Tk, Entry, Label, StringVar, W, E, N, S
class Test:
def __init__(self, master):
# Variable definitions
self.master = master
self.var1 = StringVar()
# Element definitions
self.label1 = Label(text="Dummy test")
self.entry1 = Entry(master, textvariable=self.var1)
# Grid placement
self.label1.grid(row=0, column=0, sticky=W)
self.entry1.grid(row=0, column=1, sticky=W+E)
root = Tk()
Test(root)
root.mainloop()
Original window when program is executed:
When I resize, I want the Entry to grow and shrink with the window