Tkinter: Why aren't my widgets expanding when I resize the window?
johnjsal at gmail.com
Mon Mar 5 08:12:38 CET 2012
I can't seem to wrap my head around all the necessary arguments for making a widget expand when a window is resized. I've been following along with a tutorial and I feel like I'm doing everything it said, but I must be missing something. Here's what I have. What I expect is that when I resize the main window, I should be able to see the AppFrame's border stretch out, but it remains in the original position.
Is there something wrong with the sticky argument, maybe? The tutorial I'm reading says they can be strings, but it also uses what appears to be a tuple of constants like this: sticky=(N, S, E, W) -- but that didn't work either.
import tkinter as tk
import tkinter.ttk as ttk
def __init__(self, parent, **kwargs):
self.grid(row=0, column=0, sticky='nsew')
entry = ttk.Entry(self)
entry.grid(row=0, column=1, sticky='nsew')
label = ttk.Label(self, text='Name:')
label.grid(row=0, column=0, sticky='nsew')
root = tk.Tk()
frame = AppFrame(root, borderwidth=15, relief='sunken')
More information about the Python-list