Displaying output in Static box
9 views (last 30 days)
Show older comments
Good day all, please I am working on a project that counts the blood cell, I want the output of the count to display in a static box when I click on the pushbutton "RBC Count", presently my output been printed on the command window. Please I am looking forward to your help
0 Comments
Accepted Answer
Cam Salzberger
on 26 Feb 2018
Hello Fary,
When you create the static text, you should get the handle to the object out of it. Then you can have the callback for the pushbutton modify the 'String' property of the static text. For example:
figure
hText = uicontrol('Style', 'text', 'String', 'Waiting...', ...
'Units', 'normalized', 'Position', [0 0.5 0.5 0.5]);
uicontrol('Style', 'pushbutton', 'Callback', ...
@(src, event) set(hText, 'String', 'whatever'))
Of course, if you're doing a GUIDE GUI, you will usually have all the handles to the uicontrols (and other UI elements) in the handles struct that gets passed around. In that case, just access the handle to the static text in that (named by the 'Tag' property for the text) and modify the text in the pushbutton callback.
handles.text1.String = 'whatever you want';
-Cam
More Answers (0)
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!