[Tutor] resizing Tkinter widgets

rick@niof.net rick@niof.net
Fri, 1 Feb 2002 15:40:15 -0500


On Fri, Feb 01, 2002 at 12:22:32PM -0500, Lance E Sloan wrote:
> 
> 
> It's been a while since I've posted to this list, but I've been
> lurking and reading.  I've got a Tkinter question and if it would
> be better addressed to some other mailing list, like a Tkinter
> one, please let me know.
> 
> I'm new to Tkinter and GUI programming in general.  I'm having
> trouble figuring out how to make my Listbox and Scrollbar widgets
> grow and shrink when the Tk window is resized.  Here's some
> code that I've been monkeying with, trying to make this work:
> 
> 	from Tkinter import *
> 
> 	master = Tk()
> 	master.config(bg="green")
> 
> 	frame = Frame(master, bg="blue")
> 	scrollbar = Scrollbar(frame, orient=VERTICAL)
> 	listbox = Listbox(frame, yscrollcommand=scrollbar.set, bg="red")
> 	scrollbar.config(command=listbox.yview)
> 	scrollbar.pack(side=RIGHT, fill=Y)
> 	listbox.pack(side=LEFT, fill=BOTH, expand=1)
> 
> 	listbox.insert(END, 'abc')
> 
> 	frame.pack()

    frame.pack(fill=BOTH,expand=1)

> 	master.mainloop()

You didn't tell the frame to expand so it always stays the same size.

-- 
Property is prior to law; the sole function of the law is to
safeguard the right to property wherever it exists, wherever it is
formed, in whatever manner the worker produces it, whether
individually or in association, provided that he respects the
rights of others.
	-- Frédéric Bastiat (1801-1850)
    Rick Pasotto    rickp@telocity.com    http://www.niof.net