Next: Widget commands Up: Tk Previous: Widget classes

## Inserting widgets

When widgets are created, they are inserted into the already existing widget tree. The widget tree has a root, named ``.''. All inserted widgets are children of ``.'', or a descendant of ``.''. Usually the higher-level widgets are container widgets (like frames) that define a layout structure for the interface, and the leaves of the widget tree are the widgets that the user uses to interact with the application (like buttons).

An inserted widget has a qualified name, formed by the widget path in the widget tree. The name of a widget looks like a (complete) filename in the file system. The ``/'' from the filesystem is replaced by a ``.''. The widget name reflects the location of the widget inside the widget tree.

Depending on the widget class, the user calls a command to actually create the widget. The command that is called usually is the name of the class in lowercase letters. The widget creation command may contain configuration parameters that set certain widget resources. The syntax of these parameters is described below. To create a button as a direct child of the root, the command looks like this:

``

    		button .b1 -text Quit -command {destroy .}

``.b1'' is the widget path of the widget. The following options are used to configure the button at the creation time. This command creates the widget, and creates a new Tcl command named ``.b1'', which is used to access the widget (e.g. for additional configuration, or command invocations for this widget). The widget is not displayed when it is created. It is mapped when a geometry manager is used to arrange the widget (see below).