Tkinter: Why aren't my widgets expanding when I resize the window?

John Salerno johnjsal at
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

class AppFrame(ttk.Frame):

    def __init__(self, parent, **kwargs):
        super().__init__(parent, **kwargs)
        self.grid(row=0, column=0, sticky='nsew')
        self.columnconfigure(0, weight=1)
        self.rowconfigure(0, weight=1)
    def create_widgets(self):
        entry = ttk.Entry(self)
        entry.grid(row=0, column=1, sticky='nsew')
        #entry.columnconfigure(0, weight=1)
        #entry.rowconfigure(0, weight=1)
        label = ttk.Label(self, text='Name:')
        label.grid(row=0, column=0, sticky='nsew')

root = tk.Tk()
root.title('Test Application')
frame = AppFrame(root, borderwidth=15, relief='sunken')

More information about the Python-list mailing list