Next | Prev | Up | Top | Contents | Index
Creating a Widget
Widgets belong to classes, such as Label, xmPushButton or List. For each class there is a creation command that takes the pathname of the object as its first argument:
createWidget widgetName ?managed? ?resourceList?
(This follows Tcl conventions where question mark pairs indicate an option.) Here is a summary of the command and its arguments:
- createWidget
- Specifies the type of widget you want to create. Basically, all the Motif XmCreateSomeWidget() calls bind to a corresponding xmSomeWidget call in Tcl Motif. The extensive list of Tm's supported createWidget calls appears starting with Table 4-1 below.
- widgetName
- The full pathname of the new widget, specifying both the parent widget (which should already exist) and the name of the new child.
- managed
- An option saying whether the new widget should be managed. Before a widget can be displayed, it must be brought under the geometry control of its parent. This can be done with the manageChild command, or by using the managed argument at widget creation time. This argument must appear first.
A widget might be managed but unmapped, in which case it is invisible. The main use of the "not yet managed widget" are menus (when they are not visible), and subwidgets that will resize to unknown dimensions at the time their parent is created.
- resourceList
- An optional list of resource name and string_value pairs.
Here are some examples of widget creation commands:
xmForm .form1 managed
xmLabel .form1.okLabel managed
xmPushButton .form1.cancelButton managed -labelString "Get rid of me."
This creates an xmForm called form1 as a child of "." (dot), then an xmLabel called okLabel and an xmPushButton called cancelButton, both as children of form1. The push button widget has additional arguments to set its label string to say "Get rid of me."
Next | Prev | Up | Top | Contents | Index