use of the 'uitab'

5 次查看(过去 30 天)
zhiping
zhiping 2011-6-17
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 个评论
Fangjun Jiang
Fangjun Jiang 2011-6-17
How did you create many uitabs? Please show your example.
zhiping
zhiping 2011-6-20
I add my example.

请先登录,再进行评论。

采纳的回答

Fangjun Jiang
Fangjun Jiang 2011-6-20
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 个评论
zhiping
zhiping 2011-6-20
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by