Tkinter : resizing Text widget with main window

Russell E. Owen owen at astrono.junkwashington.emu
Tue Mar 20 13:29:06 EST 2001


In article <3AB70C35.1B02410E at mega-nerd.com>,
 Erik de Castro Lopo <nospam at mega-nerd.com> wrote:

>Rick Pasotto wrote:
>> 
>> On Thu, 15 Mar 2001 19:38:12 GMT in comp.lang.python, Erik de Castro Lopo 
>> wrote:
>> > Hi all,
>> >
>> > How does one force a Tkinter.Text widget to be resized whenever
>> > the main window is resized?
>> 
>> t=Text(width=30,height=12) # sets the initial size
>> t.pack(expand=1,fill='both')
>
>That may work for widgets which are pack()ed, but what about
>widgets which are place in the parent window using grid ()?

For grid use

t.grid(sticky="news")

(Note: if you have multiple gridded widgets then you may also want to 
use the "weight" option of grid, to apportion how the various cells of 
the grid resize. This would be in addition to "sticky", not instead of 
it).

-- Russell



More information about the Python-list mailing list