Create uitab with different name (several uitabs)

3 次查看(过去 30 天)
Actually I have two questions about uitabs 1. Is "is there any problem using uitab in matlab R2014a other then the warning and documentation?" 2. Is " I want to creat a uitab group with several and different uitabs, these uitabs contain different gui components, each uitab is generated when clicking a push button so the user clicks once if he needs one uitab and twice if he needs two and so on, the general code that I use is to gather all gui components in handles structure like
Handles.fig=figure
Handles.Uitbgrp=uitabgroup('parent',handles.fig,position,...)
Handles.pb1=uicontrol(parent...,'callback',@pb1) % pushbutton
.
.
.
N=0;
Function pb1(source,event)
N=N+1
Handles.myTab1=uitab('parent',handles.uitbgrp,....)
I want that the value of handles.myTab1 changes to handles.myTabN each time the push button is triggered so I can manipulate my data easily and clearly in accordance with the overall structure of the program

采纳的回答

Charles
Charles 2015-5-29
Instead of changing a number within the name of the tab, simply make an array of tabs. In your example (after fixing a lot of capitalization issues), I come up with teh following:
function test
Handles.fig=figure;
Handles.Uitbgrp=uitabgroup('parent',Handles.fig);
Handles.pb1=uicontrol('parent',Handles.fig,'callback',@pb1) % pushbutton
N=0;
function pb1(source,event)
N=N+1;
Handles.myTab(N)=uitab('parent',Handles.Uitbgrp);
end
end
This code creates an array of tab objects as Handles.myTab(), numbered sequentially. Much better than unique alpha names, as now you can programatically reach each object. I did not embellish at all, you will need to add tab titles, button name, etc. etc.
Chuck
  1 个评论
Zine
Zine 2015-6-5
Thanks very much, it works very well, also my uicontrols I used them as arrays, thanks

请先登录,再进行评论。

更多回答(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