Resize window without covering widget
Question: This Python-tkinter program uses the pack geometry manager to place a text
widget and a "quit" button in the root window -- the text widget is above the
button.

    
    
    import tkinter as tk
    root = tk.Tk()
    txt = tk.Text(root, height=5, width=25, bg='lightblue')
    txt.pack(fill=tk.BOTH,expand=True)
    txt.insert('1.0', 'this is a Text widget')
    tk.Button(root, text='quit', command=quit).pack()
    root.mainloop()
    

When I resize the root window by dragging its lower border up, I lose the quit
button. It vanishes under the root window's border. But I'm trying to get the
quit button to move up along with the window's border, while letting the text
widget shrink. I have played with "fill" and "expand" in pack() and "height"
in both widgets without success.

Is there any straightforward way to keep the quit button visible while
dragging the window smaller?

(While researching, I noticed that grid geometry with its "sticky" cells can
accomplish this task easily. But I'm still curious to know if there is any
simple way to do the same with pack geometry.)


Answer: Pack the quit button before packing the text widget. When the window is too
small for its contents it starts to shrink widgets in the reverse order tat
they were packed until it can't shrink anymore, then it starts clipping
widgets.

The text widget, being the largest widget in your window, can shrink a lot
before it starts getting clipped.

