Matlab gui: grayed out button not working properly
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello everybody,
I have a strange problem. I want that some buttons are grayed out when doing a computation. In my button1_Callback I placed the following code:
set(handles.button1,'Enable','off');
set(handles.button2,'Enable','off');
set(handles.button3,'Enable','off');
pause(0.1)
%... doing a calculation which plots a function (total time a couple of seconds)
set(handles.button1,'Enable','on');
set(handles.button2,'Enable','on');
set(handles.button3,'Enable','on');
Like you can notice, I need to add the line pause(0.1) otherwise the code won't work. The buttons will become unclickable during the computation but not grayed out.. I tried everything but only adding this little pause will make the buttons grayed out during the computation. Somebody any idea on what's going on? It doesn't look normal that I need to add the little pause.
Thanks,
0 Commenti
Risposta accettata
Image Analyst
il 3 Dic 2013
MATLAB races ahead and gets all tied up in doing some intensive computation that it thinks is more important than processing the message to repaint your display. Putting in a pause allows it that time, but a better option is to put in a "drawnow" instead of the pause():
drawnow
This will force the operating system to repaint/refresh/update your GUI display before continuing on with the subsequent code.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!