frame
A frame widget does not do anything by itself except reserve an area of the display. Although this does not seem to have much purpose, it is a very important widget. It is a container widget; that is, it is used to group together collections of other widgets into logical groups. For example, a row of buttons may be grouped into a frame, then as the frame is manipulated so will the widgets displayed inside it. A frame widget can also be used to create large areas of color inside another container widget (such as another frame widget or a toplevel widget).
An example of the use of a frame widget as a container:
canvas .c -background red frame .f button .b1 -text button1 button .b2 -text button2 button .b3 -text button3 button .b4 -text button4 button .b5 -text button5 pack .b1 .b2 .b3 .b4 .b5 -in .f -side left pack .c -side top -fill both -expand 1 pack .f -side bottom
which specifies that there are two main widgets a canvas named .c
and a frame named .f
. There are also 5 buttons, .b1
through .b5
. The buttons are displayed inside the frame. Then
then the canvas is displayed at the top of the main window and the frame
is displayed at the bottom. As the frame is displayed at the bottom,
then so will the buttons because they are displayed inside the frame.
(The pack
command causes the widgets to be handled for display
by the packer geometry manager. The -fill and -expand 1
options to pack for .c
tell the display manager that if the
window is resized then the canvas is to expand to fill most of the
window. You will learn about geometry managers later in the Geometry
Managers section.)