How to make sure GUI is deleted before generating it again?

1 回表示 (過去 30 日間)
hana
hana 2012 年 7 月 9 日
I have a GUIDE made gui and I'd like to make sure that the figure of the gui is deleted along with all associated data (destroyed) before generating it again? (without having to manually close the gui before calling it again) Basically I want to return the gui to it's original state (all buttons return to off position.. etc.) possibly by taking action in the 'opening function'
thanks and any help is appreciated

採用された回答

Jan
Jan 2012 年 7 月 9 日
編集済み: Jan 2012 年 7 月 9 日
As far as I remember there is an "Open once only" flag in GUIDE, which include code to prevent opening multiple instances of one GUI. Please search in the menus again.
[EDITED] I've a link: http://www.mathworks.com/help/techdoc/creating_guis/f9-998364.html, and especially http://www.mathworks.com/help/techdoc/creating_guis/f9-998364.html#f9-998854. Unfortunately this feature must be selected initially. But you can create a new figure with this option and copy the created code to your existing project.
Actually you only need a unique tag for the figure and close existing figures in the OpeningFcn:
figTag = 'MyUniqueFigureTag';
oldFig = findobj(allchild(0), '-flat', 'Tag', figTag);
delete(oldFig);

その他の回答 (3 件)

Luffy
Luffy 2012 年 7 月 9 日
編集済み: Walter Roberson 2012 年 7 月 9 日
Use delete(name of ur gui) command.
A way to do it might be to put a new push button & write above command in that push button's call-back

hana
hana 2012 年 7 月 9 日
I want this to happen automatically when the gui is generated.. maybe by adding some command in "varargout" or "opening" -function..., not through a push button?!

Walter Roberson
Walter Roberson 2012 年 7 月 9 日

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by