Re: cannt disable widget timer event? [message #47212] |
Mon, 30 January 2006 21:48  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Weihua FANG writes:
> here is a examle of my code. I cancel timer event by setting a negative
> value. How will you do that?
I'd do it by removing the line that sets the timer in
the "stoptimer" part of the CASE statement. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
Re: cannt disable widget timer event? [message #47213 is a reply to message #47212] |
Mon, 30 January 2006 21:32   |
Weihua FANG
Messages: 26 Registered: January 2006
|
Junior Member |
|
|
Hi, David,
here is a examle of my code. I cancel timer event by setting a negative
value. How will you do that?
PRO timer_example_event, ev
WIDGET_CONTROL, ev.ID, GET_UVALUE=uval
IF (TAG_NAMES(ev, /STRUCTURE_NAME) EQ 'WIDGET_TIMER') THEN BEGIN
PRINT, 'Timer Fired'
WIDGET_CONTROL, ev.TOP, TIMER=1
ENDIF
CASE uval OF
'timer' : BEGIN
WIDGET_CONTROL, ev.TOP, Timer = 1
END
'otherjobs' : BEGIN
print, 'other jobs here'
END
'stoptimer' : BEGIN
; set a negative value to slope timer
WIDGET_CONTROL, ev.TOP, TIMER=-1
END
ELSE:
ENDCASE
END
PRO timer_example
base = WIDGET_BASE(/COLUMN, UVALUE='base')
b1 = WIDGET_BUTTON(base, VALUE='Fire event', UVALUE='timer')
b2 = WIDGET_BUTTON(base, VALUE='Other job', UVALUE='otherjobs')
b3 = WIDGET_BUTTON(base, VALUE='Stop Timer', UVALUE='stoptimer')
WIDGET_CONTROL, base, /REALIZE
XMANAGER, 'timer_example', base, /NO_BLOCK
END
David Fanning 写道:
> Weihua FANG writes:
>
>> just found that setting timer to a negative value would disable timer
>> event. :-)
>
> Uh, huh. And how is that different from NOT setting
> the next timer event?
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
|
|
|
Re: cannt disable widget timer event? [message #47219 is a reply to message #47218] |
Mon, 30 January 2006 18:30   |
Weihua FANG
Messages: 26 Registered: January 2006
|
Junior Member |
|
|
hi, David,
thanks for your reply.
the problem is that I have to set and cancel timer event again and
again in my application.
David Fanning wrote:
> Weihua FANG writes:
>
>> is it possible to disable widget timer event? yes, possible to avoid
>> executing part of codes in timer event procedure. but for efficient
>> consideration, is it possible to disable widget timer event like
>> disable other events, say, something like
>>
>> WIDGET_CONTROL, my_widget, DRAW_MOTION_EVENTS = 0
>>
>> WIDGET_CONTROL, my_widget, Timer_Events= 1
>> WIDGET_CONTROL, my_widget, Timer_interval= 0.2
>
> Widget timer events are one-shot events. If you don't
> set them, they don't happen. Simple as that.
>
>> Am I asking to much from IDL?
>
> Probably. I think you should ask for no events from
> your IDL programmer :-)
>
> Cheers,
>
> David
>
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
Re: cannt disable widget timer event? [message #47225 is a reply to message #47219] |
Mon, 30 January 2006 05:21   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Weihua FANG writes:
> is it possible to disable widget timer event? yes, possible to avoid
> executing part of codes in timer event procedure. but for efficient
> consideration, is it possible to disable widget timer event like
> disable other events, say, something like
>
> WIDGET_CONTROL, my_widget, DRAW_MOTION_EVENTS = 0
>
> WIDGET_CONTROL, my_widget, Timer_Events= 1
> WIDGET_CONTROL, my_widget, Timer_interval= 0.2
Widget timer events are one-shot events. If you don't
set them, they don't happen. Simple as that.
> Am I asking to much from IDL?
Probably. I think you should ask for no events from
your IDL programmer :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
Re: cannt disable widget timer event? [message #47360 is a reply to message #47212] |
Tue, 07 February 2006 02:43  |
Weihua FANG
Messages: 26 Registered: January 2006
|
Junior Member |
|
|
well, thanks for your reply.
David Fanning wrote:
> Weihua FANG writes:
>
>> here is a examle of my code. I cancel timer event by setting a negative
>> value. How will you do that?
>
> I'd do it by removing the line that sets the timer in
> the "stoptimer" part of the CASE statement. :-)
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|