Tkinter: Why aren't my widgets expanding when I resize the window?
rantingrickjohnson at gmail.com
Mon Mar 5 14:09:07 CET 2012
On Mar 5, 1:12 am, John Salerno <johnj... at gmail.com> wrote:
> I can't seem to wrap my head around all the necessary arguments
> for making a widget expand when a window is resized.
You will need to configure the root columns and rows also because the
configurations DO NOT propagate up the widget hierarchy! Actually, for
this example, I would recommend using the "pack" geometry manager on
the frame. Only use grid when you need to use grid. Never use any
functionality superfluously! Also, you should explicitly pack the
frame from OUTSIDE frame.__init__()!
## START CODE ##
import tkinter as tk
import tkinter.ttk as ttk
from tkinter.constants import BOTH, YES
def __init__(self, parent, **kwargs):
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')
## END CODE ##
> 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.
I always use either:
More information about the Python-list