Re: Progress Bar - Cancel button problem [message #85575 is a reply to message #85560] |
Sun, 18 August 2013 21:40  |
moxament
Messages: 26 Registered: April 2008
|
Junior Member |
|
|
On Friday, August 16, 2013 8:09:58 AM UTC-4, David Fanning wrote:
> MAhmad writes:
>
>
>
>> I created my own progress bar in idl. The progress bar works perfectly and show progress! my problem is with the cancel button. During the progress of whatever process, the cancel button can not be pressed. I mean when I want to push/click the cancel button while the process is working, the button can not be clicked/pushed (it looks like freezing). The cancel button can be pressed only when the progress is finished (when became 100%).
>
>>
>
>> I tried all the options of the widget_base, widget_button, etc. with no hope!
>
>>
>
>> Can anyone help please?
>
>
>
> The trick is to check for the button event yourself in your loop, using
>
> Widget_Event with the NoWait keyword set:
>
>
>
> event = Widget_Event(self.cancelID, /NoWait)
>
>
>
> You can see how this is done in the CheckCancel method of this progress
>
> bar:
>
>
>
> http://www.idlcoyote.com/programs/cgprogressbar__define.pro
>
>
>
> The code to use the bar, and check for the button events, looks like
>
> this:
>
>
>
> cgProgressBar = Obj_New("CGPROGRESSBAR", /Cancel)
>
> cgProgressBar -> Start
>
> FOR j=0,9 DO BEGIN
>
> IF cgProgressBar -> CheckCancel() THEN BEGIN
>
> ok = Dialog_Message('The user cancelled operation.')
>
> RETURN
>
> ENDIF
>
> Wait, 0.5 ; Would probably be doing something ELSE here!
>
> cgProgressBar -> Update, (j+1)*10
>
> ENDFOR
>
> cgProgressBar -> Destroy
>
>
>
> Cheers,
>
>
>
> David
>
>
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Thank you David. I will try your hint and see what I can get.
Cheers,
MA
|
|
|