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 Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by