Updating text in a GUI
5 views (last 30 days)
Show older comments
I have a GUI and I am trying to use a static text as a status so for example when I push a button that does some calculation I want the user to know that is calculating and the user should wait.
When the user push the button I put in the callback function first, before anything else
message = cell(2,1);
message{1}='Please wait...';
message{2}='Getting times ';
set(handles.status, 'String', message);
set(handles.status, 'BackgroundColor', [1 1 0]);
at the end after the function that does the calculation I put
message = cell(2,1);
message{1}='READY';
message{2}='Times acquired';
set(handles.status, 'String', message);
set(handles.status, 'BackgroundColor', [0 1 0])
but what is happening is that I never see the first message, only the second message when the calculation finishes, how can I change that?
thank you in advance...
0 Comments
Answers (1)
Joseph Cheng
on 11 Dec 2015
Edited: Joseph Cheng
on 11 Dec 2015
one of the many questions is how long is the calculation? if it is quick enough (i don't know how quick is quick) matlab maynot update the GUI until after the function ends.
for instance i don't have the same issue and i push my pause() statement in my dummy pushbutton1 callback pretty quick
message = cell(2,1);
message{1}='Please wait...';
message{2}='Getting times ';
set(handles.status, 'String', message);
set(handles.status, 'BackgroundColor', [1 1 0]);
for ind = 1:10
set(handles.pushbutton1,'string',num2str(ind));
pause(0.1)
end
message = cell(2,1);
message{1}='READY';
message{2}='Times acquired';
set(handles.status, 'String', message);
set(handles.status, 'BackgroundColor', [0 1 0])
my advice is put a breakpoint using the debugger and step through your code. watching the GUI see that as you step through to the point the text should change. if it does change then its probably something graphical. I don't know an equivalent command like drawnow for handle structures.
0 Comments
See Also
Categories
Find more on Environment and Settings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!