Re: Passing info and destroying widgets... [message #15883 is a reply to message #15879] |
Mon, 21 June 1999 00:00   |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Robert King (kingrj2@bp.com) writes:
> I eventually created a separate event handler to destroy the widgets, eg
>
> Pro kill_widgets, event
> Widget_Control, event.top,/DESTROY
> END
>
> This worked with no errors!
>
> I'd like to know if there is another way around this problem as it seems
> rather strange behavoir.
"Strange" is not the word that comes to my mind when something
works with no errors. I would think it is "strange" to destroy
the top-level base and then imagine you could stick something
in its non-existent user value. But, then, that's just me. :-)
I used to write elaborate work arounds for this problem,
sometimes using WIDGET_INFO to make sure the top-level base
is still living before I stuffed something into it:
IF WIDGET_INFO(event.top, /Valid_ID) THEN $
WIDGET_CONTROL, event.top, Set_UValue=info, /No_Copy
But now I *always* have a separate event handler for the
QUIT button that does nothing but destroy the top-level
base. As Struan notes, all your clean-up should be done
in a CLEANUP routine. Doing it anywhere else means you
are going to miss it at least half the time.
I like this object-like programming approach. It's simple,
it's elegant, and it works like a charm. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|