#! /usr/sgitcl/bin/moat xtAppInitialize -class Program xmMainWindow .main managed xmForm .main.form managed xmList .main.form.list managed xmPushButton .main.form.btn1 managed xmPushButton .main.form.btn2 managedThe xmForm acts as what is called the "workWindow" of the mainWindow. This resource would be set as follows:
.main setValues -workWindow .main.formValues would also be set into the list and buttons:
.main.form.list setValues \ -itemCount 3 -items "one, two, three" \ -selectionPolicy single_select .main.form.btn1 setValues -labelString Quit .main.form.btn2 setValues -labelString "Do nothing"Callbacks are set up for the Quit button and the selection list:
.main.form.btn1 activateCallback {exit 0} .main.form.list singleSelectionCallback {puts stdout "Selected %item"}Geometry would be set for the form, placing all objects in correct relation to each other. This produces a list on the left, with the two buttons above and below on the right:
.main.form.list setValues \ -topAttachment attach_form \ -leftAttachment attach_form \ -bottomAttachment attach_form .main.form.btn1 setValues \ -topAttachment attach_form \ -leftAttachment attach_widget \ -leftWidget .main.form.list .main.form.btn2 setValues \ -topAttachment attach_widget \ -topWidget .main.form.btn1 \ -leftAttachment attach_widget \ -leftWidget .main.form.listSince we initially created all the widgets as managed, it is not necessary to explicitly manage them before entering the main loop.
Finally, windows are created and the main event loop is entered:
. realizeWidget . mainLoopOnce entered in the main event loop, the application is really running: widgets are created, displayed, and manipulated as user events that trigger associated callbacks.