简体   繁体   中英

Correct Usage of uiwait and uiresume in MATLAB App Designer

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.
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')

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.

For now, I am using this as a work around instead of using uiwait and uiresume

a = 150;
b = 200;
rolls =zeros(1)
APPINFO = matlab.apputil.install('./APP/app');
matlab.apputil.run('appAPP')  % GUI will return rolls
while isequal(rolls,zeros(1)) == 1
    pause   
end
c = a+ b + rolls;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM