How to get current status of the process in the edit box in gui matlab?
12 views (last 30 days)
Show older comments
I have an existing code. Let it be c1.m. Now I have created a gui(c2.m ,c2.fig) for the user. I put an edit box for the current status of the process. Now what I want is whenever the code execution starts, the current status box should display the messages like featuring,extracting(just names) i.e., the entire process. How can I do that? One more problem that I am encountering is whenever I run code using GUI, the GUI automatically closing and it is opened after the completion of entire process.
0 Comments
Answers (1)
Jan
on 7 Mar 2018
Something equivalent in the code of the GUI:
handles.FigH = figure('Tag', 'UniqueAndDescriptiveTagName');
handles.EditH = uicontrol('Style', 'Edit');
guidata(handles.FigH, handles);
And in the function for the calculations:
function YourCalculations
FigH = findobj(allchild(groot), 'flat', 'Tag', 'UniqueAndDescriptiveTagName');
if length(FigH) ~= 1
error('Cannot find an open GUI');
end
handles = guidata(FigH);
% Just for demonstration:
for k = 1:10
set(handles.EditH, 'String', datestr(now, 0));
pause(0.2);
end
It might look smarter, if you start the calculations from a callback of the GUI, e.g. by a push-button. Then you can provide the required handles as inputs already:
function ButtonCallback(hObject, EventData, handles)
YourCalculations(handles);
end
And the header of the function the calculations:
function YourCalculations(handles)
set(handles.EditH, 'String', 'Started...');
...
end
0 Comments
See Also
Categories
Find more on Interactive Control and Callbacks 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!