App Designer - how to run code before components are created?

I would like to run MATLAB code before the components of the app are initialized. The default workflow is
function app = time_evolution_app_R2_0_v18_resized
% Create and configure components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.MulticellularModelSimulatorUIFigure)
% Execute the startup function
runStartupFcn(app, @startupFcn)
if nargout == 0
clear app
end
end
Therefore, the first editable code is placed after createComponents() and registerApp() are called. Is there any way to place code before runStartupFcn()?
Specifically, I have a bunch of graphics I use for buttons in the app, which I would like to store in a subfolder. However, the only possibility seems to either (1) place the graphics in the same folder as the app, (2) manually add the subfolder with graphics to my MATLAB path. Is there any way to automatically add a subfolder to the path when running the app, before the app components are created?

7 comentarios

Greg
Greg el 15 de Jul. de 2019
This is a rather annoying feature of the App Designer. Would be nice to have some feedback from MathWorks on this.
If you save your .mlapp as a .m in appdesigner, you can edit the script itself. Then just run the .m script to run your app.
It does not work to me, I keep opening file with all wierd symbols
How could I edit it?
Ankit
Ankit el 8 de Oct. de 2019
Editada: Ankit el 8 de Oct. de 2019
I think you renamed the file. Have you tried exporting from the app designer?
yes, sorry, you're right
It worked
Will Reeves
Will Reeves el 14 de Mzo. de 2023
Editada: Will Reeves el 14 de Mzo. de 2023
Can I confirm that since October 2019 this reasonable "feature request" hasn't been included?... Or maybe an "advance mode" option that allows a user to freely edit all areas of code?
As of R2022a, images do not need to be on the MATLAB path to be used in App Designer.
There is a workaround to call addpath with a dummy propery variable
properties (Access = private)
dummyvariable = addpath('./icons')
end

Iniciar sesión para comentar.

Respuestas (1)

Laura V.
Laura V. el 17 de Abr. de 2023
I'm dealing with the same problem but due to another reason. I would like to implement a Matlab version check before createComponents. Implementing a version check in startupFcn would be too late for features like wordwrap that cause an error with older Matlab versions in createComponents....

Categorías

Más información sobre Develop Apps Using App Designer en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 17 de Mayo de 2018

Respondida:

el 17 de Abr. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by