GUI with changeable number of tabs

조회 수: 2 (최근 30일)
Mus'ab Ahmad
Mus'ab Ahmad 2015년 7월 10일
댓글: Mus'ab Ahmad 2015년 7월 19일
Greetings, How can I create changeable number of tabs in matlab gui? I mean based on the content inserted in the main tab (let say number 4), then a number of tabs (4 tabs) should appear in addition to the main one.

채택된 답변

Richa Gupta
Richa Gupta 2015년 7월 15일
Hi Mus’ab,
It is possible to create changeable number of tabs in a MATLAB GUI. Below is an example of how to do that:
figure
tabgp = uitabgroup(gcf); %create a tab group
tab1 = uitab(tabgp,'Title','Main Tab'); %create the main tab
hbox = uicontrol('Parent', tab1, 'Style', 'edit', 'String', '0', 'HorizontalAlignment', 'left', 'Position', [80 320 170 25],'Callback',{@create_new_tabs,tabgp}); %create an edit box in the main tab from where the user can specify the number of tabs to be inserted; add a callback function create_new_tabs
function create_new_tabs(hObject,callbackdata,tabgp)
for x = 1:str2num(hObject.String) %create the number of tabs entered by the user
tab.(['t' num2str(x)]) = uitab(tabgp,'Title',['Tab' num2str(x)]);
end
end
I hope this helps.
-Richa
  댓글 수: 1
Mus'ab Ahmad
Mus'ab Ahmad 2015년 7월 19일
It works, thanks a lot Richa

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by