Colored Widget Buttons
QUESTION: Is it possible to create colored widget buttons in IDL?
ANSWER: I'm not sure it is officially possible, but I have hacked up some code Dick Jackson provided to the IDL newsgroup for another purpose. The essence of this code is to create a true-color bitmap that can be used as the value of a WIDGET_BUTTON to give the effect of a colored button. I simply modified it to accept FGCOLOR and BGCOLOR (foreground color and background color) keywords so the buttons can be colored appropriately. You can see an example of the buttons in the figure below.
|An example of colored widget buttons.|
I used this code to produce the buttons.
tlb = Widget_Base(/Row, /Exclusive) button1 = Widget_Button(tlb, Value=ColorButtonBitmap('Button 1')) button2 = Widget_Button(tlb, Value=ColorButtonBitmap('Button 2', $ FGCOLOR='YELLOW', BGCOLOR='NAVY')) button3 = Widget_Button(tlb, Value=ColorButtonBitmap('Button 3', $ BGCOLOR='YELLOW', FGCOLOR='INDIAN RED')) Widget_Control, tlb, /Realize
You can find the ColorButtonBitmap program in the program section of Coyote's Guide to IDL Programming. You will also need to download other Coyote Library programs to use the program, specifically cgColor, cgErrorMsg, and cgPickColorName.
Copyright © 2007 David W. Fanning
Last Updated 25 May 2007