comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Interrupting widget applications
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Interrupting widget applications [message #7943 is a reply to message #7940] Thu, 23 January 1997 00:00 Go to previous messageGo to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
M Hegde <hegde@news.gsfc.nasa.gov> writes:

> What is the best way to interrupt a loop in widget applications?.
> According to my IDL knowledge, IDL doesn't support concurrency; so I can't
> have a button/widget to do that. Ctrl-C is not a smart way as it exits the
> application. Any suggestions?.

Here is the most important suggestion: Don't write loops in widget
event handlers! Instead, take advantage of the fact that a widget
program *is itself* a loop. I have several examples of what I
mean on my web page. Take a look at the programs XMOVIE and
ZIMAGE for two ways to take advantage of the widget program
as a loop.

Alright, so sometimes there just isn't any other way. What then?

Then, you have a button that can "cancel" the loop. I have a
"show progress" widget example that you can download from
my anonymous ftp site. The idea is that something that takes
a lot of time is going on. (In this example, a BIG calculation.)
I want to allow the user to see the progress of the calculation
and I want them to be able to cancel the calculation if they
don't want to wait.

Here is the relevant section of the code that is inside the big
calculation loop. The variable info.cancel is the ID of the
CANCEL CALCULATION button. Notice that I am using
WIDGET_EVENT to look for an event directly. This is about
the *only* time I manage events myself. The rest of the
time I use XMANAGER.

; Did the "Cancel Operation" button get clicked?
; Look for an event. Don't turn off the hourglass cursor!

progressEvent = Widget_Event(info.cancel, /NoWait)

; Is this a button event?

eventName = Tag_Names(progressEvent, /Structure_Name)
IF eventName EQ 'WIDGET_BUTTON' THEN BEGIN

; If it IS a button event, destroy the show progress widget and
; issue an informational message to the user to alert him or her.

Widget_Control, info.top, /Destroy
result = Widget_Message('Operation Canceled!!', /Information)

; Escape from the loop. Interrupt code would go here.

GoTo, outSideLoop

You can download the "show progress" example program via anonymous
ftp from ftp.frii.com. It is in the directory:

/pub/dfanning/outgoing/idl_training/showprog.pro

Compile the program and type "test" to see it work:

IDL> .Compile showprog
IDL> test

Let me know if you have questions.

Yours,

David

-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
2642 Bradbury Court, Fort Collins, CO 80521
Phone: 970-221-0438 Fax: 970-221-4762
E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com
-----------------------------------------------------------
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: display many color images
Next Topic: Re: color buttons

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 14:04:03 PDT 2025

Total time taken to generate the page: 1.92036 seconds