Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #21223
| From | John Salerno <johnjsal@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Tkinter: Why aren't my widgets expanding when I resize the window? |
| Date | 2012-03-04 23:12 -0800 |
| Organization | http://groups.google.com |
| Message-ID | <32271364.3080.1330931558529.JavaMail.geo-discussion-forums@ynjd19> (permalink) |
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)
self.create_widgets()
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')
root.mainloop()
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Tkinter: Why aren't my widgets expanding when I resize the window? John Salerno <johnjsal@gmail.com> - 2012-03-04 23:12 -0800
Re: Tkinter: Why aren't my widgets expanding when I resize the window? Rick Johnson <rantingrickjohnson@gmail.com> - 2012-03-05 05:09 -0800
Re: Tkinter: Why aren't my widgets expanding when I resize the window? John Salerno <johnjsal@gmail.com> - 2012-03-05 09:31 -0800
Re: Tkinter: Why aren't my widgets expanding when I resize the window? Rick Johnson <rantingrickjohnson@gmail.com> - 2012-03-05 11:03 -0800
Re: Tkinter: Why aren't my widgets expanding when I resize the window? John Salerno <johnjsal@gmail.com> - 2012-03-05 14:07 -0800
Re: Tkinter: Why aren't my widgets expanding when I resize the window? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-03-06 01:10 +0000
Re: Tkinter: Why aren't my widgets expanding when I resize the window? John Salerno <johnjsal@gmail.com> - 2012-03-05 17:53 -0800
Re: Tkinter: Why aren't my widgets expanding when I resize the window? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-03-06 01:58 +0000
Re: Tkinter: Why aren't my widgets expanding when I resize the window? Rick Johnson <rantingrickjohnson@gmail.com> - 2012-03-05 18:20 -0800
Re: Tkinter: Why aren't my widgets expanding when I resize the window? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-03-06 02:33 +0000
Re: Tkinter: Why aren't my widgets expanding when I resize the window? Rick Johnson <rantingrickjohnson@gmail.com> - 2012-03-05 18:56 -0800
Re: Tkinter: Why aren't my widgets expanding when I resize the window? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-03-06 03:09 +0000
Re: Tkinter: Why aren't my widgets expanding when I resize the window? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-03-05 12:25 -0500
csiph-web