If I have already created an App, but then want to add Tabs, is it better to do this through the App Designer interface or "programmatically"? Any hints to expedite the process?

8 次查看(过去 30 天)
That is, there is code existing already, so if I add "Tabs", how do I get my existing code into the Tab of my choice?
  1. Should I (for example...) start an entirely new App and begin with Tabs? Or
  2. Add Tabs to my existing App using the App Designer interface, and rearrange the existing App code into the tabs? Or,
  3. Add tabs _ programmatically,_ and put the new Tab code so as to encompass the existing code that I want on that Tab?
  4. Other ???

回答(1 个)

TED MOSBY
TED MOSBY 2025-8-20,8:16
Hi,
If your tabs are static (i.e., not created/destroyed dynamically based on data), the fastest approach is to use App Designer’s Component Library: drop in a Tab Group, create a few tabs, and move your existing components under the right tabs.
If you need tabs at runtime (e.g., variable number of tabs), then you can create them programmatically in startupFcn and reparent existing controls into the desired tab.
% Create a Tab Group and two tabs
app.TabGroup = uitabgroup(app.UIFigure);
t1 = uitab(app.TabGroup, 'Title','Data');
t2 = uitab(app.TabGroup, 'Title','Plots');
% Reparent existing components into tabs
app.LoadButton.Parent = t1;
app.UIAxes.Parent = t2;
Here is some documentation for reference:
Hope it helps!

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by