First Example and Basic Steps
This section briefly introduces the basic steps involved in creating a Wave Widgets application.
First Example
The following example incorporates the basic steps described later in this section. To run this example, enter the callback procedure in a file, and compile it with the .RUN command. Then enter the widget commands at the
WAVE> prompt. A radio button box appears. Clicking on a radio button, executes the callback procedure and information prints in the PV-WAVE window. The radio box is shown in
Figure 5-4: Radio Buttons (Motif style).
To dismiss the radio box widget, select the appropriate function (such as Close) from the widget’s window manager menu.
Callback Procedure
Callback procedures are routines that are executed in response to an event that occurs inside a widget, such a mouse click.
PRO RadioCB, wid, which
CASE which OF
1: PRINT,'First Toggle Selected'
2: PRINT,'Second Toggle Selected'
3: PRINT,'Third Toggle Selected'
ENDCASE
value = WwGetValue(wid)
PRINT, value
END
Widget Commands
top=WwInit('ww_ex1', 'Examples', layout)
labels=['System','Owner','Group']
rbox=WwRadioBox(layout,labels, 'RadioCB', /Vertical, Border=2, $
Spacing=20)
status=WwSetValue(top, /Display)
WwLoop
The Basic Steps
To use Wave Widgets in an application, you always follow these basic steps. These steps are described in more detail in the remainder of this chapter.
Create callback procedures. Callback procedures are routines that are executed in response to an event, such as clicking a button or dismissing a dialog box.
Initialize Wave Widgets with the WwInit function. For example:
top = WwInit('appl', 'Appl', layout)
Create widgets by calling the appropriate Wave Widgets functions. All Wave Widgets function names begin with Ww. For example:
bbox=WwButtonBox(layout, labels, 'ButtonCB',$
/Horizontal, Spacing=20)
Display the top-level widget with the WwSetValue command and the
Display keyword. For example:
status=WwSetValue(top, /Display)
Execute the WwLoop function. This function executes the “event loop”, which handles events (such as mouse clicks) and dispatches callbacks (routines that are executed in response to events).