Path: news.mathworks.com!not-for-mail
From: "Yair Altman" <altmanyDEL@gmailDEL.comDEL>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Tempoarily Disable a GUI while a function is running
Date: Wed, 12 Sep 2007 08:09:55 +0000 (UTC)
Organization: TACT Computer Systems Ltd
Lines: 40
Message-ID: <fc86sj$lim$1@fred.mathworks.com>
References: <fc71me$ouq$1@fred.mathworks.com>
Reply-To: "Yair Altman" <altmanyDEL@gmailDEL.comDEL>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1189584595 22102 172.30.248.38 (12 Sep 2007 08:09:55 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 12 Sep 2007 08:09:55 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 642467
Xref: news.mathworks.com comp.soft-sys.matlab:428018


"Adam " <not.my.email@mathworks.com> wrote in message
<fc71me$ouq$1@fred.mathworks.com>...
> I have a complicated function that take awhile to run.  I
> have set up a GUI using GUIDE to handle different variables.
>  The problem I have is the user can click the run button, or
> a slider control multiple times.  This calls multiple
> instances of the function, with bizarre results.  In a
> couple cases enough functions are called to crash Matlab.
> 
> I tried making the waitbar() modal.  However, you can still
> sneak in 2-3 button presses.  Even worse, if you click a
> slider control it locks and then proceeds to repeatedly push
> the slider button (calling a function instance every time)
> until it reaches the max limit!!!
> 
> I'm pretty sure the following code will work:
>     set(hObject, 'Enable', 'off')
>     
>     set(handles.lblWait, 'String', 'Thinking ...')
>     pause(0.01)
>     fcnTestPlot(fVal, handles);   % <-- this is "long" fcn
> 
>     pause(0.01)
>     set(handles.lblWait, 'String', '')
>     set(hObject, 'Enable', 'on')
> 
>  It seems like a bit of a hack; i.e. is there a better way?


You might wish to use my "enable/disable figure" submission
on the File Exchange:
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=15895
- it disables the entire figure, as well as all contained UI
controls and menus, in a single command. After your callback
function ends, you can call this function again to re-enable
the figure.

Yair Altman
http://ymasoftware.com