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

Home » Public Forums » archive » Re: Interrupting a loop in a GUI
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 a loop in a GUI [message #38469] Thu, 11 March 2004 12:48
robert.dimeo is currently offline  robert.dimeo
Messages: 42
Registered: November 2001
Member
Florian,

You can use a timer widget for just this purpose. Just set up the
timer to fire every 1 second (or however long you need). You set up
your event handler to detect a widget timer event and then issue
another timer firing from there. Your event handler should also be
able to process events from other widgets in your application such as
a "PAUSE" button.

The short example below illustrates this:

Good luck,

Rob

; **********************
pro timer_example_cleanup,tlb
widget_control,tlb,get_uvalue = pstate
heap_free,pstate
end
; **********************
pro timer_example_event,event
widget_control,event.top,get_uvalue = pstate
uname = widget_info(event.id,/uname)
case uname of
'quit': widget_control,event.top,/destroy
'start': $
begin
(*pstate).loop = 1B
timer_id = widget_info(event.top,find_by_uname = 'timer')
widget_control,timer_id,timer = (*pstate).duration
end
'pause': (*pstate).loop = 0B
'timer': $
begin
if (*pstate).loop then begin
timer_id = widget_info(event.top,find_by_uname = 'timer')
widget_control,timer_id,timer = (*pstate).duration

; Florian, this is where you would put the code to acquire
; your camer images...here we'll just update the label widget.

label_id = widget_info(event.id,find_by_uname = 'display')
widget_control,label_id,get_value = val & val = float(val)
widget_control,label_id,set_value = $
strtrim(string(val+(*pstate).duration),2)
endif
end
else:
endcase
end
; **********************
pro timer_example
tlb = widget_base(title = 'Timer Example', $
/tlb_frame_attr,/col)
base = widget_base(tlb,/col,uname = 'timer')
void = widget_label(base,value = '0',/dynamic_resize, $
uname = 'display')
void = widget_button(base,value = 'Start',uname = 'start')
void = widget_button(base,value = 'Pause',uname = 'pause')
quit = widget_button(base,value = 'Quit',uname = 'quit')


widget_control,tlb,/realize
state = {loop:0B,timer_id:base,duration:0.25}
pstate = ptr_new(state,/no_copy)
widget_control,base,timer = (*pstate).duration
widget_control,tlb,set_uvalue = pstate
xmanager,'timer_example',tlb,/no_block, $
cleanup = 'timer_example_cleanup'

end


ebertf@gmx.de (Florian Meyer) wrote in message news:<14e53261.0403110526.2d08e791@posting.google.com>...
> I wrote a GUI for displaying a camera picture that looks like this:
> There�s a display for the pic, some buttons to set display parameters
> and a button to START the camera.
> My problem is, when I press the START button, the event starts an
> infinite loop in my _eventcb program that is aquiring pictures from
> the camera forever...
>
> The question now is:
> How can I interupt a loop from another button, i.e. how can I create
> the STOP button on my GUI Surface. Or how can I change parameters
> during the camera loop is running.
>
> Usually IDL waits until the process in the _eventcb is finished before
> it executes another thing from the GUI Surface.
> I guess there is a very simple answer, but I don't know it... :-)
>
> Florian
[Message index]
 
Read Message
Previous Topic: Re: IDL JavaBridge on Mac OS X
Next Topic: color problem when capture the object window

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

Current Time: Sun Oct 12 12:21:54 PDT 2025

Total time taken to generate the page: 1.99778 seconds