How to remove UI windows after a bug
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Thomas Barbier
am 2 Okt. 2019
Bearbeitet: Adam Danz
am 2 Okt. 2019
Hi all,
I have a script that creates a waiting UI bar for the time of the for loop:
wb = waitbar(0,'Name','My waitBar');
for t = 0:t_end
do_stuff(t, other_stuff);
waitbar(t / span(end), wb);
end
delete(wb);
However, when I try some things in do_stuff, I sometimes (often) have errors. So the script stops, but the UI windows remain and is impossible to close.
I thought a try/catch thing, but is there an easier way to get rig of those ghost windows?
0 Kommentare
Akzeptierte Antwort
Adam Danz
am 2 Okt. 2019
Bearbeitet: Adam Danz
am 2 Okt. 2019
I think it's a bad idea to automatically close the figure whenever there's an error since the figure may contain information that helps to diagnose the problem.
To close the figure manually, select the figure and then delete or force-close.
figure('CloseRequestFcn', [])
delete(gcf)
% or
close(gcf,'force')
[Update]
uifigure('CloseRequestFcn',[])
closereq
6 Kommentare
Adam Danz
am 2 Okt. 2019
Bearbeitet: Adam Danz
am 2 Okt. 2019
Glad I could help.
There's nothing wrong with your interpretation of "UI Figure" since that's exactly what it implies - a user interface figure. However, matlab's function to create app designer figures is uifigure() which produces a different type of figure with different properties than figure(). Both can be used to create a user interface.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Interactive Control and Callbacks 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!