gui with guide into a script file
古いコメントを表示
i have made 2 files a gui that asks whattypes of stuff and the quantities then an ok button that gets all the quantities, and i want to use this file in another m script, vut i dont know how to please help.
function fpok_Callback(hObject, eventdata, handles)
guidata(hObject,handles);
clc
% fpmcstr=string(get(handles.chkfpmc,'string'))
% fpcoystr=string(get(handles.chkfpcoy,'string'))
% fprgstr=string(get(handles.chkfprg,'string'))
% fpblkstr=string(get(handles.chkfpblk,'string'))
% fpmcbstr=string(get(handles.chkfpmcb,'string'))
% fparidstr=string(get(handles.chkfparid,'string'))
%
%
%the below is to make a struct of all the values entered by the user
fpres=struct('FlatpackMC',nan,'FlatpackCOY',nan,'FlatpackRG',nan,'FlatpackBLK',nan,'FlatpackMCB',nan,'FlatpackArid',nan)
fpmcv=get(handles.chkfpmc,'Value');%if the checkbox is checked
fpcoyv=get(handles.chkfpcoy,'Value');
fprgv=get(handles.chkfprg,'Value');
fpblkv=get(handles.chkfpblk,'Value');
fpmcbv=get(handles.chkfpmcb,'Value');
fparidv=get(handles.chkfparid,'Value');
if fpmcv==1;%if the checkbox is checked
fpmcqt1=handles.fpmcqt.String; % this calls the number entered in the edit box
fpres.FlatpackMC=str2double(fpmcqt1);% makes that number into a number
end
if fpcoyv==1;
fpcoyqt1=handles.fpcoyqt.String;
fpres.FlatpackCOY=str2double(fpcoyqt1);
end
if fprgv==1;
fprgqt1=handles.fprgqt.String;
fpres.FlatpackRG=str2double(fprgqt1);
end
if fpblkv==1;
fpblkqt1=handles.fpblkqt.String;
fpres.FlatpackBLK=str2double(fpblkqt1);
end
if fpmcbv==1;
fpmcbqt1=handles.fpmcbqt.String;
fpres.FlatpackMCB=str2double(fpmcbqt1);
end
if fparidv==1;
fparidqt1=handles.fparidqt.String;
fpres.FlatpackArid=str2double(fparidqt1);
end
handles.output=fpres
guidata(hObject,handles);
%uiresume(ancestor(hObject, 'flatpack'))
closereq()
this is the gui call back for the ok button
fpmcqt=0;fpcoyqt=0;fprgqt=0;fpblkqt=0;fpgyqt=0;fpmcbqt=0;
fp=questdlg('Flatpacks','Select','Yes','No','c');
switch fp
case 'Yes'
result=Flatpack %was told this calls the gui it does but i cant get the values
end
disp(fpres.fpmcqt)%this is just for the mc one but it runs before you can enter a value for it
this is what someone told me to do for the call back ive tried changing the fpres to the gui file name "Flatpack" and the paper name "flatpack"
1 件のコメント
Walter Roberson
2021 年 5 月 31 日
How does this differ in technology from the discussion at https://www.mathworks.com/matlabcentral/answers/842565-use-a-custom-made-gui-in-another-m-file?s_tid=prof_contriblnk ?
回答 (2 件)
Walter Roberson
2021 年 5 月 31 日
closereq()
Do not do that. closereq() deletes the figure, but the handles structure is stored as part of the figure, so you are deleting the saved information about what to return the caller. You need to use the uiresume() instead of closereq() .
13 件のコメント
Joseph Catanese
2021 年 5 月 31 日
Image Analyst
2021 年 5 月 31 日
@Joseph Catanese, can you just attach both the entire fig file and m file with the paper clip icon? Make it easy for people to help you.
Joseph Catanese
2021 年 5 月 31 日
編集済み: Joseph Catanese
2021 年 5 月 31 日
Walter Roberson
2021 年 5 月 31 日
You coded as
uiresume(ancestor(hObject, 'flatpack'))
but the code I posted for you before was
uiresume(ancestor(hObject, 'figure'))
Here figure is an object type. ancestor() climbs the chain of Parent of the given object until it finds a containing object whose type is the given type -- figure in this case. So given any object any number of layers down inside a figure, ancestor() with 'figure' would return the handle of the figure that the object resides inside.
Joseph Catanese
2021 年 6 月 1 日
Joseph Catanese
2021 年 6 月 1 日
Walter Roberson
2021 年 6 月 1 日
You can have the Output Function delete the figure... after you have extracted the information from handles. And as I showed in the other Question, it would return a struct that you would assign to a variable and then extract the parts of.
Joseph Catanese
2021 年 6 月 1 日
Joseph Catanese
2021 年 6 月 1 日
編集済み: Joseph Catanese
2021 年 6 月 2 日
Joseph Catanese
2021 年 6 月 1 日
Joseph Catanese
2021 年 6 月 6 日
Walter Roberson
2021 年 6 月 6 日
Still waiting for the .fig that Image Analyst asked for a week ago.
Joseph Catanese
2021 年 6 月 11 日
編集済み: Joseph Catanese
2021 年 6 月 11 日
Image Analyst
2021 年 5 月 29 日
0 投票
Several ways are shown in the FAQ:
Write back if none of them work for you and attach your m-file, fig file, and any files needed at runtime to launch your program.
カテゴリ
ヘルプ センター および File Exchange で Graphics Object Properties についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!