Problems in saving GUI's handles structure

3 ビュー (過去 30 日間)
gaia buratti
gaia buratti 2012 年 12 月 2 日
Hi,
I made a GUI using nested functions (without GUIDE). It has some Edit, pushbuttons and a chart. The GUI works well as I run it, but I would like to save it as figure and than be able to modify it in the future. I am new to GUI's programming, but I red that I should update the handles structure with the new handles (buttons and so on) using guidata function but it doesn't work. It look like the new handles are not saved in the structure. Here is just a piece of code, to show what I did with one of the handles, I hope someone can help me.
if true
function Gann5
set(0,'Units','pixels')
scnsize = get(0,'ScreenSize');
f = figure('Toolbar','none','position',[0,0,scnsize(3),scnsize(3)]);
handles=guihandles(f);
handles.hfreq = uicontrol('Style','popupmenu',...
'String',{'d','w','m'},...
'Position',[scnsize(3)-70,280,60,25],...
'Callback',{@popup_menu_Callback});
guidata(f,handles);
end
I tried putting a brekpoint and the handles struct. contains hfreq too, but if I run without breakpoints and then I tipe on the command window:
a=guihandles(gcf);
The handle structior does not contain hfreq. I'm sorry if it is a stupid question but I am stuck on this.
Thanks in advance.
Gaia

採用された回答

Jan
Jan 2012 年 12 月 2 日
The function guihandles creates a struct using the tags of the graphic objects as fieldnames and the handles of the objects as values. But the guidata function stores a struct in the figure's ApplicationData. Therefore the replies of these two functions are not directly related.
Try this instead to find the hfreq field:
data = guidata(gcf)
It increases the confusion level, that TMW decided to call the struct for storing GUI related data "handles" also as default.
  1 件のコメント
gaia buratti
gaia buratti 2012 年 12 月 3 日
Great!!! It works, now I can save my gui as fig and then when I open it again i can work on it just recalling handles=guidata(f). Thanks a lot!
Gaia

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by