On Mar 5, 1:12 am, John Salerno <johnj...@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

class AppFrame(ttk.Frame):
    def __init__(self, parent, **kwargs):
        super().__init__(parent, **kwargs)
        self._create_widgets()

    def _create_widgets(self):
        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()
root.title('Test Application')
frame = AppFrame(root, borderwidth=15, relief='sunken')
frame.pack(fill=BOTH, expand=YES)
root.mainloop()
## 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:

 sticky='nswe'
 sticky=N+S+W+E
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to