Fanning Software Consulting

Creating Invisible iTools

QUESTION: I want to programmatically create an iTool and save it without user interaction. I have managed to do that (see the code below), but is it possible to do this without having the tool appear on the display at all?

   IDL> iPlot, findgen(10)
   IDL> idTool = itgetcurrent(tool=oTool)
   IDL> idSave = oTool -> FindIdentifiers('*save',/operations,count=count) 
   IDL> oSave = oTool -> GetByIdentifier(idSave)
   IDL> oSave -> SetProperty, filename='iplot.isv'
   IDL> idExit = oTool -> FindIdentifiers('*exit',/operations,count=count)
   IDL> void = oTool -> doAction(idExit)

ANSWER: The answer was provided by Chris Torrence, an ITTVIS employee, in a 5 September 2006 IDL newsgroup article.

Yes, there is an undocumented keyword (it's actually documented under IDLitSys_CreateTool). If you set USER_INTERFACE="None", then it will not display any UI. For example:

   iPlot, findgen(10), user_interface='none'
   void = oTool->DoSetProperty('Operations/File/Save', 'filename', 'iplot.isv')
   void = oTool->DoAction('Operations/File/Save')
   void = oTool->DoAction('Operations/File/Exit')

Now before you run off and try this, there is a bug in IDL 6.2 and IDL 6.3 where the "Save" operation will not work correctly if there is no UI. Other operations such as "Print" and "Export" should work fine. For example, you could do the following instead:

   ; Print the window.
   ; First disable the Print dialog.
   void = oTool->DoSetProperty('Operations/File/Print', 'SHOW_EXECUTION_UI', 0)
   void = oTool->DoAction('Operations/File/Print')

   ; Export the window to a JPEG file.
   ; First disable the Export wizard dialog.
   void = oTool->DoSetProperty('Operations/File/Export', 'SHOW_EXECUTION_UI', 0)
   ; Export the entire window.
   void = oTool->DoSetProperty('Operations/File/Export', 'SOURCE', 1)
   void = oTool->DoSetProperty('Operations/File/Export', 'FILENAME', 'iplot.jpg')
   void = oTool->DoAction('Operations/File/Export')

We are planning on exposing this functionality in a future version of IDL, as well as fixing the bug with "Save".

Web Coyote's Guide to IDL Programming