Borrar filtros
Borrar filtros

How do I get a Matlab UI (app) to call another UI so that it appears that my app has multiple pages?

10 visualizaciones (últimos 30 días)
I am looking for a code example that will show me how to call another UI. I can not find any decent examples of this online. I have been trying to get a push button to call this other UI.
classdef App1 < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
Button matlab.ui.control.Button
end
methods (Access = private)
% Button pushed function: Button
function ButtonPushed(app, event)
% (WHAT GOES HERE TO CALL OTHER UI?) <----------------
end
end
% App initialization and construction
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Create UIFigure
app.UIFigure = uifigure;
app.UIFigure.Position = [100 100 640 480];
app.UIFigure.Name = 'UI Figure';
setAutoResize(app, app.UIFigure, true)
%
% Create Button
app.Button = uibutton(app.UIFigure, 'push');
app.Button.ButtonPushedFcn = createCallbackFcn(app, @ButtonPushed, true);
app.Button.Position = [271 264 100 22];
end
end
end
Thank you to anyone who helps!

Respuesta aceptada

dbmn
dbmn el 30 de Nov. de 2016
There are two possibilities:
a) create a new "Tab" in your existing GUI with uitab
b) just call the other Gui in the button press function like you would call any script or function.
c) About passing data or variables.
  • You could pass the variables directly (depending on how your GUI is written)
  • Please DON'T use global variables to share the content
  • Use "setappdata" instead
  • Or write your data to a temporary *.mat file that you load in the second GUI
  • It might be possible to nest the second GUI within the first one, although I'm not 100% sure if this will work.
  • if all else fails use "assignin" and send the vars to base workspace

Más respuestas (0)

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by