use of the 'uitab'

5 views (last 30 days)
zhiping
zhiping on 17 Jun 2011
hello, I use 'uitab' to create many uitabs, finally I want to initial all the parametres, how to remove all of uitabs except one? Thanks in advance. Here is the example:
function example
k=1;
screensize=get(0,'ScreenSize');
h(1)=figure('Name','example','Color',[0.831372549019608 0.815686274509804 0.784313725490196],...
'Position',[100 100 screensize(3)-500 screensize(4)-400],'NumberTitle','off','Resize','off','MenuBar','none');
h(10) = uitabgroup('Parent',h(1),'Position',[0.2 0.6 0.92 0.33]);
h(14) = uicontrol('Parent',h(1),'Units','normalized','Callback',@pushbutton3_Callback,...
'Position',[0.1 0.8 0.1 0.15],'String','Add uitab','Style','pushbutton','Enable','on');
h(15) = uicontrol('Parent',h(1),'Units','normalized','Callback',@pushbutton4_Callback,...
'Position',[0.1 0.6 0.1 0.15],'String','initial','Style','pushbutton','Enable','on');
function pushbutton3_Callback(obj,event)
create_tab(k);
k=k+1;
end
function pushbutton4_Callback(obj,event)
k=1;
h(10) = uitabgroup('Parent',h(1),'Position',[0.2 0.6 0.92 0.33]);
create_tab(k);
end
function create_tab(idx)
h(11+100*(idx-1)) = uitab('Parent',h(10),'Title',['tab' num2str(idx)]);
end
end
I use a button to initial the parametre, made k=1, but it doesn't look right.
  2 Comments
Fangjun Jiang
Fangjun Jiang on 17 Jun 2011
How did you create many uitabs? Please show your example.
zhiping
zhiping on 20 Jun 2011
I add my example.

Sign in to comment.

Accepted Answer

Fangjun Jiang
Fangjun Jiang on 20 Jun 2011
First of all, reformat your code portion of your question as {}Code so it's more readable to human eyes. By first glimpse, your function didn't have the right input argument. The only input to your create_tab(idx) function is the variable idx. But inside the function, you are using h(10) as the handle of the parent GUI.
  1 Comment
zhiping
zhiping on 20 Jun 2011
hi, I'm a little stupid, just make k=1, and re-write h(10),then callback create_tab(k), the problem is solved. Anyway, thinks a lot.

Sign in to comment.

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!