[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: xwindow and ps_form questions




Brad Gom <gombg@uleth.ca> writes:
> 
> I've been trying to add a xwindow widget to my widget program. I have
> two problems:
> 
> 1)  when I use xwindow within a widget program (ie I call xwindow to run
> a plot routine
>     when a certain widget event occurs) the plot works fine. I can
> resize properly.
>     (xwindow works perfectly when I call it from a non-widget program)
>     But, when I try to configure a postscript file for output, I get the
> following error:
> 
> > % XMANAGER: Caught unexpected error from client application. Message follows...
> > % Variable is undefined: CANCEL.
> >
>     It seems that the main xwindow routine is not waiting for the
> ps_form routine to return its structure.  The
>     error occurs on this line in xwindow:
> ...

Yes, Brad should have mentioned that he was running my version of the
program.  Up until now, I haven't put any strenuous demands on XWINDOW
in IDL 5, since we still are mostly an IDL 4 group.  (You may say
"ugghh", but then again, all of these wierd modal-problems in IDL 5
seem pretty ridiculous. ... and who needs objects anyway?  chuckle)

David -- and other interested parties -- I have updated PS_FORM and
XWINDOW to conform to David's posting on the subject from last June.
I have ran them through IDL versions 4 to 5.1 and they work now.

 http://astrog.physics.wisc.edu/~craigm/idl/idl.html

[Donning Scrooge jacket ... ] A pox upon RSI for changing widgets like
this!

Here seems to be an elegant and no nonsense way to get your modal
widgets back without too much hassle:

 1. Read David's posting on modal and blocking widgets from June 15,
    1998.  It's on DejaNews.
 2. If your widget program will be called by *another* widget
    program, then make sure the group leader can be passed in
    via a parent keyword (a la David's suggestion).
 3. Construct your top level base with this snippet

  IF double(!version.release) GE 5 AND n_elements(parent) GT 0 THEN $
    widget_modal = {Modal:1, Group_Leader:parent(0)}
  tlb = Widget_Base(Column=1, whatever_you_want, _EXTRA=widget_modal)

 4. Invoke XMANAGER with this snippet:

  IF double(!version.release) LT 5 THEN xmanager_modal = {Modal:1}
  XManager, 'myfunc', tlb, _extra=xmanager_modal

How does it work?  The main time there are problems is when you want
one widget program to call another widget program.  As long as the
'parent' is passed into your program, the first snippet makes sure
that WIDGET_BASE is called with the right parameters.  The second
snippet calls XMANAGER with the MODAL keyword if needed.  I use the
tricky _EXTRA parameter to avoid maintaining two lines of code which
do essentially the same thing.

One added benefit is that widgets created like this work properly on
both IDL 4 and IDL 5, a win for me.  

Craig

-- 
--------------------------------------------------------------------------
Craig B. Markwardt, Ph.D.         EMAIL: craigmnet@astrog.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
--------------------------------------------------------------------------