Fanning Software Consulting

IDL Widget Programs

These are demonstation widget programs of various sorts.



This simple function creates a true-color bitmap that can be used to create a colored widget button. I used the following code to create the figure below.
   tlb = Widget_Base(/Row, /Exclusive)
   button1 = Widget_Button(tlb, Value=ColorButtonBitmap('Button 1')) 
   button2 = Widget_Button(tlb, Value=ColorButtonBitmap('Button 2', $
   button3 = Widget_Button(tlb, Value=ColorButtonBitmap('Button 3', $
   Widget_Control, tlb, /Realize

The TextBox Program.



The purpose of this compound widget object is to allow the user to click a small color patch or rectangle and have a new color selection dialog widget appear so a new color can be selected. The functionality is demonstated in the Coyote Program cgPickColorName.



The purpose of this compound widget object is to provide an alternative to the droplist widget (Widget_Droplist) offered in the IDL distribution. What has always annoyed me about a droplist is that you can’t get the current “value” of a droplist easily. This compound widget makes this and other tasks much easier.



This compound widget is designed as a more-or-less drop-in replacement for the RSI-supplied CW_Field program. It is an ill-conceived precursor (which I have tried desperately not to support) to FSC_INPUTFIELD. If you aren't really sure about objects, use this program instead of FSC_INPUTFIELD. If you are ready to go for it, use FSC_INPUTFIELD, the officially supported version of these two similar programs.



This compound widget is a file selection tool I find I use over and over in my own programming. I wanted a way for the user to be able to select either a directory name or a file name. Writing the program as an object gave me a great deal of power over how I handle absolute or relative file names. Here is what the program looks like in a top-level base by itself:

The FSC_FileSelect object compound widget program.



This compound widget is designed as a more-or-less drop-in replacement for the RSI-supplied CW_Field program. There are several things I have never liked about CW_Field, but the the foremost thing is that on Windows machines the text widget input box is grayed out and does not look as if it is editable. Without this visual clue, users are confused about how CW_Field works. This program is more flexible and powerful than CW_Field. One of the ways it is more powerful is that it is possible to set the fields up so that users can tab from one field to the next and have the text in the fields automatically selected for editing. An example program at the end of the code shows you how this is done. Compile the program file first to run the example.

The FSC_InputField Program.



A simple example of the proper way to write a pop-up dialog widget program that returns information to the caller. The program can be used to return a single piece of information from the user. For example, to ask the user for the name of a variable to store a processed image at the main IDL level, you might type something like this:
   varname = TextBox(Title='Provide Main-Level Variable Name...',, $
      Label='Variable Name: ', Cancel=cancelled, XSize=200, Value='stretched_image')
   IF NOT cancelled THEN BEGIN
      displayImage = BytScl(*info.image,,  $
         Max=info.maxThresh, Min=info.minThresh)
      dummy = Routine_Names(varname, displayImage, Store=1)

See Writing Pop-Up Dialog Widgets for a discussion of this program.

The TextBox Program.



A simplified XInterAnimate program that shows you the correct way to implement an animation loop in a widget program with a Widget_Timer event.

Version of IDL used to prepare this article: IDL 7.0.1.

Last Updated: 21 March 2011