The flow of control in a widget application is fundamentally different than in other IDL programs. A program written to be used from the IDL command line generally accepts its inputs when the program is invoked. The program then proceeds in a well-defined order to process those inputs and provide some output; a calculated value, a plot, an image, etc. In contrast, widget applications are event driven.
In an event driven system, the program creates an interface and then waits for messages (events) to be sent to it from the window system. Events are generated in response to user manipulation, such as pressing a button or moving a slider. The program responds to events by carrying out the action or computation specified by the programmer, and then waiting for the next event.
This approach to computing is fundamentally different from the traditional command-based approach. Actions occur in the order specified by the user at runtime, rather than in the order determined by the programmer. The widget application model and programming techniques are discussed later in this section. Events from IDL widgets are generated in the form of an IDL structure variable specific to the widget. Widget events and event-processing are also discussed in detail.
This section discusses topics related to creating widget user interfaces, controlling widgets, processing events generated by user interaction, and managing the application state of a widget application. The section starting with Working with Widget Events explores using specific types of widgets in widget applications and discusses methods for creating specific types of interfaces and applications.
Running the Example Code
The example code used in this section is part of the IDL distribution. All of the examples developed these sections are included as .pro files in the examples/doc/widgets subdirectory of the IDL distribution. By default, this directory is part of IDL’s path; if you have not changed your path, you will be able to run the examples as described here. See !PATH for information on IDL’s path.
In addition to the examples developed here, a number of simple examples of widget programming can be seen by running the IDL program wexmaster.pro, located in the /examples/widgets/wexmast folder of the IDL distribution. A widget interface with a pulldown menu of small widget applications should appear.