To provide a function for the push button so that when it is pressed a message appears in the terminal window and the script terminates, you have to add a callback. Also, you must tell the push button about the existence of this callback. The following is the script with the new code added:
#!/usr/dt/bin/dtksh activateCB() { echo "Pushbutton activated; normal termination." exit 0 } XtInitialize TOPLEVEL dttest2 Dtksh $0 XtSetValues $TOPLEVEL title:"dttest2" XtCreateManagedWidget BBOARD bboard XmBulletinBoard $TOPLEVEL \ resizePolicy:RESIZE_NONE \ background:SkyBlue \ height:150 width:250 XtCreateManagedWidget BUTTON pushbutton XmPushButton $BBOARD \ background:goldenrod \ foreground:MidnightBlue \ labelString:"Push Here"\ height:30 width:100 x:75 y:60 shadowThickness:3 XtAddCallback $BUTTON activateCallback activateCB XtRealizeWidget $TOPLEVEL XtMainLoop
The callback is the function activateCB(). You typically add the callback to the push button after it (the push button) has been created:
XtAddCallback $BUTTON activateCallback activateCB
Now the pushbutton knows about the callback. When you click the push button, the function activateCB() is executed, and the message "Pushbutton activated; normal termination." appears in the terminal window from which you executed the script. The script is terminated by the call to the function exit 0().