SCO Visual Tcl Reference Guide
Chapter 3, SCO Visual Tcl - graphical scripting language

Basic SCO Visual Tcl architecture

Basic SCO Visual Tcl architecture

An SCO Visual Tcl program consists of a main section and a number of procedures. The program is event-driven. The main section is invoked when the program first starts; it puts up display elements on the screen and then goes into a loop waiting for user input. The rest of the procedures are called in response to user input, such as pressing a button, or entering data into a text field. These procedures are referred to as callbacks.

The basic display element in SCO Visual Tcl is a widget such as a pushbutton or menu. The dialog widget is a special type of widget that presents a window on the screen and is used as a container for other widgets. A typical SCO Visual Tcl application consists of presenting the user with a number of dialogs and having the user respond to the information.

Each of the widgets in a dialog can be customized with different options. For instance, the label on a pushbutton, the items in a list, the size and position of the widget, fonts, and so on can all be configured.

Each widget is identified by a name. The programmer can specify options for each widget on the command line. These options include geometry options (such as the position of the widget), object class options (associated properties of the object, such as an error callback, font, height, width, and so on), label options (that define labels, accelerator keys and mnemonics), and form or dialog options (applicable only to forms or dialogs). There are also generic additional callback options that are applicable to any widget.

Widgets are defined hierarchically, similarly to the Tk conventions (see John K. Ousterhout's Tcl and the Tk Toolkit (Addison-Wesley, 1994)). Object names contain the entire widget hierarchy of the branch the widget resides on, to distinguish between identical child widgets located on different branches of the widget tree; for example, toplevel.child1.child2.widget. Therefore, to create a widget it is usually only necessary to refer to its widget name (within the context of its parent object), but to modify or manipulate an existing widget it is necessary to use its object name (which is unique) to distinguish it from other widgets of the same type elsewhere in the ``applet''. (An applet is a Tcl script that invokes SCO Visual Tcl; an application refers to the SCO Visual Tcl daemon, Tcl interpreter, and the applet script currently being executed.)

The application enters an event loop, displaying a form (or forms), collecting data returned by SCO Visual Tcl, and acting upon the data until the user wishes to leave the application. The program sets up the form and widgets on it, and executes the form using the VtMainLoop(VTCL) command. Execution of subtasks relies on the callback mechanism. When an exit condition is reached, a VtClose(VTCL) command is issued, ending the application's connection to SCO Visual Tcl.