필터 지우기
필터 지우기

Correct Usage of uiwait and uiresume in MATLAB App Designer

조회 수: 40 (최근 30일)
Vasista Adupa
Vasista Adupa 2020년 6월 19일
댓글: Vasista Adupa 2020년 6월 19일
I am really having confusion where to place this both commands `uiwait` and `uiresume`
I am using app designer in matlab. and I am having this GUI in the middle of the code, so for the program to stop until this GUI complete, I am using these commands.
I tried placing
`uiwait` in `app startupFcn`
function startupFcn(app)
uiwait(app.UIFigure)
end
And `uiresume` in
function UIFigureCloseRequest(app, event)
uiresume(app.UIFigure)
delete(app)
end
But ended with errors
`Error using getappdata Value must be a handle`
My GUI will close when I press a Button because I assigned `closereq` at the end of that Button callback function.
Let me know if any further info is needed.

답변 (1개)

Ajit Kasturi
Ajit Kasturi 2020년 6월 19일
  댓글 수: 2
Vasista Adupa
Vasista Adupa 2020년 6월 19일
Thanks for the links, I saw it earlier, But It didn't provide exact syntaxes similar to one in app designer. I tried this,
I did create a small GUI which has a continue button, when pressed exits the GUI. From my understanding uiwait should start as soon as the figure starts, so that my code in the background can stop executing. Here's a simple code I ran.
%% Script written to test it%%%%%%%%%
a = 150;
b = 200;
APPINFO = matlab.apputil.install('./APP/app');
matlab.apputil.run('appAPP')
c = a+ b + rolls;
%%%%%%% This is a part of the code from app designer Code View %%%%%%%%
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
uiwait(app.UIFigure)
end
% Button pushed function: ContinueButton
function ContinueButtonPushed(app, event)
if app.ContinueButton.Enable
roll = 1500;
assignin("base","rolls",roll);
closereq
end
end
end
In the Background it is saying as Pause (which is what I needed), But when I click on the continue button an error pops up.
Error using getappdata
Value must be a handle.
Error in appApp/attachOncleanupToFigure (line 109)
appdata = getappdata(fig);
Error in appApp/startApp (line 94)
obj.attachOncleanupToFigure(appdesigner.internal.service.AppManagementService.getFigure(obj.AppHandle));
Error in appApp (line 48)
startApp(obj)
Error in appinstall.internal.runapp>execute (line 116)
out = evalin('caller', [script ';']);
Error in appinstall.internal.runapp>runapp13a (line 95)
outobj = execute(fullfile(appinstalldir, [wrapperfile 'App.m']));
Error in appinstall.internal.runapp>preamble18b (line 60)
appobj = runapp13a(appinstalldir);
Error in appinstall.internal.runapp (line 13)
out = preamble18b(appinstalldir);
Error in matlab.apputil.run (line 45)
appinstall.internal.runapp(appName, appLocation);
Error in trail_uwait_uresume (line 7)
matlab.apputil.run('appAPP')
It might be trivial, But I am not getting it honestly.
Thank you.
Vasista Adupa
Vasista Adupa 2020년 6월 19일
For now, I am using this as a work around.
a = 150;
b = 200;
rolls =zeros(1)
APPINFO = matlab.apputil.install('./APP/app');
matlab.apputil.run('appAPP')
while isequal(rolls,zeros(1)) == 1
pause
end
c = a+ b + rolls;

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by