Re: xwindow and ps_form questions [message #14032] |
Tue, 19 January 1999 00:00 |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
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
------------------------------------------------------------ --------------
|
|
|
Re: xwindow and ps_form questions [message #14035 is a reply to message #14032] |
Tue, 19 January 1999 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
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:
>
>> PRO XWINDOW_CONFIGURE_FILES, event
>> WIDGET_CONTROL, event.top, GET_UVALUE=info, /NO_COPY
>> ; What kind of file to configure?
>> WIDGET_CONTROL, event.id, GET_VALUE=whichFile
>> CASE whichFile OF
>> 'Configure PostScript File...': BEGIN
>> newkeywords = PS_FORM(DEFAULTS=info.ps, $
>> LocalDefaults=info.pslocal, Cancel=cancel, Create=create)
>> IF NOT cancel THEN info.ps = newkeywords
>>
> What special precautions do I need to take when including xwindow
> in a widget program?
None. Download the latest versions of both programs. When IDL
changed the Modal behavior in IDL 5, I had to update the way
the program behaved. The proper call in the latest version of
XWindow is this:
'Configure PostScript File...': BEGIN
newkeywords = PS_FORM(DEFAULTS=info.ps, Parent=event.top, $
LocalDefaults=info.pslocal, Cancel=cancel, Create=create)
Where the PARENT keyword is used to pass a group leader to the PS_FORM
top-level base. A group leader is *required* to create a proper modal
widget.
You can get the latest versions here:
http://www.dfanning.com/programs/xwindow.pro
http://www.dfanning.com/programs/ps_form.pro
> 2) I want to register the xwindow when I create the main widget
> hierarchy. How do I plot to the
> existing xwindow, and retain the ability to resize and output?
This is a good idea to want to plot to the existing XWindow, but
the program was never designed with that requirement in mind. In fact,
what I specifically had in mind was to write a program that would
serve as an model for how you could write a resizeable window
for *your* program requirements.
If you really want to plot into the existing XWindow, then I suggest
you re-write the guts of XWindow as an object. It wouldn't take more than
a couple of hours, I think. I'll leave it as a programming exercise for
the user. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Progamming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
[Note: This follow-up was e-mailed to the cited author.]
|
|
|