Matlab gui: grayed out button not working properly
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
Image Analyst
am 3 Dez. 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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!