Correct Usage of uiwait and uiresume in MATLAB App Designer

21 visualizaciones (últimos 30 días)
Vasista Adupa
Vasista Adupa el 19 de Jun. de 2020
Comentada: Vasista Adupa el 19 de Jun. de 2020
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.

Respuestas (1)

Ajit Kasturi
Ajit Kasturi el 19 de Jun. de 2020
  2 comentarios
Vasista Adupa
Vasista Adupa el 19 de Jun. de 2020
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 el 19 de Jun. de 2020
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;

Iniciar sesión para comentar.

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by