X

Help Articles are product support tips and information straight from the NV5 Geospatial Technical Support team developed to help you use our products to their fullest potential.



1347 Rate this article:
No rating

How to add Greek letters (or other special characters) into an IDL widget button

The IDLDE Editor supports some UTF-8 characters, but the IDL Console and Widgets do not, so you may see differences in the way some characters are displayed in different areas of IDL. Widgets can be especially tricky since they use device (system) fonts. You will be at the mercy of the available fonts on your operating system as to what shows up in your widget. This can be challenging for developers hoping to get a consistent multi-platform experience with their widget application. 
 
One indirect work-around is to skip system fonts and instead just apply a bitmap texture to the widget button. The below approach will do the trick, though it's not ideal. The main drawback is slowdown. On MacOS at least, initializing new graphics the first time will have a ~5 second penalty. On Windows and Linux, it will be almost instantaneous. Another option would be to include the generated bitmap files in your application itself, and thus not have to generate them on the fly. However, you could run into a situation where the background/text colors don't match the rest of the widget on a specific platform or specific machine.
 
Find more information about IDL function graphics HERE
 
Here is some IDL PRO code that demonstrates how to add a Greek letter to a widget button: 
 

;Make new graphics version of bitmap

;Draw a hidden widget to retrieve the system default colors

Base = Widget_Base(/Row)

Widget_Control, Base, Map = 0

Colors = Widget_Info(Base, /System_Colors)

ForegroundColor = N_elements(Foreground_Color) ne 3 ? $

  Colors.Button_Text : $

  Foreground_Color

BackgroundColor = N_elements(Background_Color) ne 3 ? $

  Colors.Face_3D : $

Background_Color

      ;Draw a hidden graphics window with the needed character

w=window(/buffer, dimensions=[200,200],background_color=BackgroundColor)

t=text(0.5,0.5,'$\sum$',font_size=10,color=ForegroundColor)

 

;Draw the real widget and include a copy of the hidden graphics window as an image for the button

t = widget_base(/row)

b2=widget_button(t,value='S',font='symbol') ;This method works on Windows, but may fail on other platforms

b3=widget_button(t,value=transpose(w.CopyWindow(border=3),[1,2,0])) ;This is the work-around which is cross-platform

widget_control,t,/realize

 

 

 

 

 

 

Created by BC-US 12/15/2022, Reviewed by JU 12/27/2022

Please login or register to post comments.
Featured

End-of-Life Policy Enforcement for ENVI 5.3 / IDL 8.5 and Earlier Versions

5/6/2024

April 1, 2024 Dear ENVI/IDL Customer,  We are reaching out to notify you of our supported... more »

How to Upgrade licenses to ENVI 6.x / IDL 9.x

12/5/2023

What is the new Upgrade function? Starting with ENVI 6.0 and IDL 9.0, we have implemented an... more »

What to do if the 'License Administrator - License Server' for the Next-Generation License Server does not start?

6/13/2023

Background: With the release of ENVI 5.7 & IDL 8.9 and the corresponding Next-Generation licensing... more »

Next-Generation Licensing FAQ

4/28/2023

  NV5 Geospatial has adopted a new licensing technology for all future releases of our ENVI, IDL... more »

The IDL Virtual Machine

6/6/2013

What is the IDL Virtual Machine? An IDL Virtual Machine is a runtime version of IDL that can... more »