frm = Frame(root, bd=5, relief=RAISED)
frm.pack(padx=5, pady=5)
gridbox(frm)
Label(root, text='Pack:').pack()
frm = Frame(root, bd=5, relief=RAISED)
frm.pack(padx=5, pady=5)
packbox(frm)
Button(root, text='Quit', command=root.quit).pack()
mainloop()
When this runs we get a composite window with two forms that look identical (Fig-
ure 9-31), but the two nested frames are actually controlled by completely different
geometry managers.
Figure 9-31. grid and pack in the same window
On the other hand, the sort of code in Example 9-21 fails badly, because it attempts to
use pack and grid within the same parent—only one geometry manager can be used
on any one parent.
Example 9-21. PP4E\Gui\Tour\Grid\grid2-fails.py
"""
FAILS-- can't grid and pack in same parent container (here, root window)
"""
Grids | 569