Creating a frame widget

The frame widget is used as a container for other widgets. Although it works in and of itself, it accepts no input from the user nor does it provide feedback. It simplifies the layout of complex screens and adds to the appearance of the final product. To add a widget to a frame, we use the following syntax:


% 1 frame .f
% 2 button .f.b -text "My Button"

The naming hierarchy in Tcl is such that we prepend the name of the container. In this case, a frame is prepended to the button to instruct the interpreter that the button is contained within a container. A container can be a window, top level, canvas, or frame, as in the previous example.

The keywords are described in the Tk main pages as follows:

Standard keywords

Get Tcl/Tk 8.5 Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.