Sunday, March 12, 2017

[Matlab GUI] Create the tab UI using GUIDE

This example shows how to create tab.

M script
----------------------------------------------------------------
% Prepare a tab-group consisting of two tabs
hTabGroup = uitabgroup; drawnow;
% Define tab position
% Set(hTabGroup,'Position',[.1 .2 .5 .3]);
set(hTabGroup,'Position',[.1 .2 .8 .5]);

% Set two tabs "Panel 1" and "Panel 2" as child 
tab1 = uitab(hTabGroup, 'title','Panel 1');
a = axes('parent', tab1); surf(peaks);
tab2 = uitab(hTabGroup, 'title','Panel 2');
uicontrol(tab2, 'String','Close', 'Callback','close(gcbf)');
h2=uitabgroup('parent',tab2); %drawnow;

% Set the tab "Panel 2" as parent
set(h2,'Position',[.2 .3 .3 .2]);
% Set two tabs "t1" and "t2" as child of "Panel 2"
t1 = uitab(h2,'title','t1');
t2 = uitab(h2,'title','t2');
----------------------------------------------------------------

Download "guide_tab.fig" and "guide_tab.m"

No comments:

Post a Comment