File Exchange

image thumbnail

TabManager - Create Tab Panels (uitabgroup) from a GUIDE GUI

version 1.6.0.0 (41.1 KB) by Grant
Convention based method which allows a tabbed GUI to be designed using GUIDE

30 Downloads

Updated 10 Mar 2018

View License

This class allows users to create a GUI using GUIDE that supports a tabbed UI.
Since GUIDE doesn't directly support the uitabgroup control, this class allows tabs to be created as standard panels that are at run time converted to uitab controls.
Usage:
1. Create a pane with tag set to Tab? where ? is any letter or number (e.g. TabA). This main pane should be left empty and determines the size and location of the tab group (uitabgroup)
2. Create additional panes with a tag name that starts with the name of the main pane. All other controls should be added to these panes.
3. In the Guide generated function xxx_OpeningFcn add the following:
handles.tabManager = TabManager( hObject );

Comments and Ratings (63)

Grant

Have you had a look at the example "TabManagerExample" included in the zip? Try modifying the figure TabManagerExample.fig using Matlabs "guide" program. There are also instructions at the top of TabManager.m

How can I use it? I am lost

Yanjun Han

Hello Grant,
sorry for the wrong question, not for use Tab manager, for another toolbox

Hello Grant,
I have used the tabManager to create a few TabGroups, each equipped with a SelectionChangedFcn. But sometimes it seems that the wrong function executes, e.g. on a Change in TabGroupC the tabChangedB function executes. Is there a way to prevent this? I think it happens because the tabGroups Change Position for some reason and then the wrong SelectionChangedFcn is applied to the wrong TabGroup.

Hi Grant,
I have mailed you.

Grant

Hi Rupesh, you can send to developit at gmail.com

Hi Grant,
Sure. What is your email id?

Grant

Hi Rupesh, Can you email me the m & fig file that shows this problem?

Hi Grant,I have created a guide page 'pageA' having tabs TabA(Main Tab) followed by child tabs TabAchild1,TabAchild2 and TabAchild3. All these tabs are created using TabManager and they are working fine. I am using Matlab 2017a version. As part of my implementation I have a close button on each of the child tab. If I press the close button on any child tab, the 'pageA' should get closed. Basically in the callback of this button I am using command 'close(pageA);'. But i am getting an error saying 'Panel TabAchild1 must not be a child of its main pane TabA(which must be an empty panel)'. Am I missing something here?

Grant

Hi Patrick, for some reason, my comments don't seem to be saving permanently.
The example, TabManagerExample.m that is part of the submission has code on the "Main" and "Supplementary" buttons that sets the selected tab. The same property can be used to get the active/selected tab.

tabMan = handles.tabManager;
tabMan.Handles.TabA.SelectedTab = tabMan.Handles.TabA01Main;

Grant

.

Grant

Hi Patrick, probably obvious, but when I mentioned "the example", I was referring to the example TabManagerExample.m that is part of the submission.

Hello Grant, is there a way to get the currently active tab?

Harry Wei

Grant

Hi Sebastian, you can get the figure handles from any callback by calling
handles = guihandles

Thank you Grant,
I really appreciate your work and help for the community!
But I wonder, how could i get my handles as an input of the tabChangedCB function?
I want to change Tabs in another TabGroup depending on which tab is currently selected.
Sorry, it's not obvious to me. :)

Grant

Hi exploder123, Unfortunately, Matlab doesn't support setting size, color etc on tabs (apart from via undocumented java calls).

Hello Grant, thank you very much for this manager, this is amazing.

Is there a way to change the color of the tab heading (the small area where tab title is displayed)?

Thank you very muhc.

Grant

Hi Paul, The problem relates to the order in which Matlab adds to a parents Children array and how the tab order is the reverse of the Children array order. I've changed TabManager so that it now preserves the GUIDE tab order.

Grant

Hi Timon, thanks for your improvement suggestion and code. I've put this into the latest release (and modified the example to included nested tab groups

Hi Grant, outstanding submission. Thank you. I've noticed that when I use TabManager, the tab ordering of the individual components (i.e. which component gets focus when pressing the Tab key on the keyboard) is actually the reverse of what is shown in GUIDE's Tab Order Editor. Has anyone else noticed this, and/or have an explanation?
Thanks!

Manuel

Works like a charm on Matlab 2017

Timon

Hi Grant,
Thank you very much for the very useful and handy tabmanager! I tried to make nested GUIs and struggled first. Then I slightly modified the function TabManager (in the for loop of the ownerPanels):
parent = get(panelOwner,'Parent');
tabGroup = uitabgroup('Parent', parent, 'Units', units, 'Position', pos, 'Tag', ownerTag );

If an owner panel is located within a tab of another tab group the new owner panel gets again the tab as a parent. If you like that too you could add this to your code.
Thanks!

Badar

Dear Grant,
No, I did not changed the source file Tabanager.m, exactly error is in my tabmanage.m file.
And now, the error is removed after switching my work on 2017a Matab.
You done a Great job by creating this Tab panels :)

Thanks

Grant

Hi Badar,Have you renamed/changed TabManager.m? The errors you are getting are from the function/class TabManage (not TabManager). I don't think its the TabManager that is causing the problem.

Badar

Hi Grant,
I am using your Tabmanager program in my GUI, I successfully created tabs, but when I programmed components in tabs it displaying this error, and my Tanmanage.m file is blank now after run the program.
please guide me in this regard, Thanks in advance.

Error using TabManage
Too many input arguments.

Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)TabManage('edit14_CreateFcn',hObject,eventdata,guidata(hObject))
Error using TabManage
Too many input arguments.

Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)TabManage('edit13_CreateFcn',hObject,eventdata,guidata(hObject))
Error using TabManage
Too many input arguments.

Badar

UNAL

Grant

Hi Donya, I've updated TabManager.m so that the background colour of a placeholder panel is now copied to its corresponding uitab.

Hi,
Thanks for sharing :) I have implement it and it works fine but when I'm trying to change the color of the panels it doesn't work and it goes back to the default grey color. I was wondering if you have defined the color somewhere in your function or is something wrong with my program!

Thanks in advance :)

Grant

Hi Trung Tran, yes, you can set a callback function via the SelectionChangedFcn property of the tab group. I've updated the example (TabManagerExample.m) to show how to do this.

Trung Tran

Hi Grant,
This is a amazing. I would like to ask is it possible to execute a callback function after I select the tabe manually?

Grant

Hi Oldemonium, you probably have the panels that represent the tabs as children of the panel that represents the main pane. Drag your panels (TabA01 etc) out of the main pane (TabA) so that they're children of the figure. The new version (1.03) of TabManager that I uploaded recently generates a more descriptive error message that should make it easier to diagnose this problem.

Oldemonium

Hi, Grant and ifree. How did toi solve your problem ? I currently have the same.

help ifree

Grant

Hi ifree, not sure why this is happening. Did you try TabManagerExample (the example included)? Did that work for you? What's different between the example and your code? You can send me your code/fig if you'd like me to work out what's happening. Send to developit at gmail.com

help ifree

Hi Grant, thanks for your share. I created 3 panels in a guide figure, taged with TabA, TabA01 and TabA02, and I added
handles.tabManager = TabManager( hObject ); in the openning function, when I run it gone error. My version is 2015b,
Could you help me, thanks!

Error using handle.handle/get
Invalid or deleted object.

Error in TabManager (line 98)
panelTag = get(hPanel,'Tag');

Error in tabtest>tabtest_OpeningFcn (line 57)
handles.tabManager = TabManager( hObject );

Error in gui_mainfcn (line 220)
feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure), varargin{:});

Error in tabtest (line 42)
gui_mainfcn(gui_State, varargin{:});

Grant

Hi Hyun-Gwang, Matlab tabs have fairly limited features and I don't think you can hide/enable them.

thank you, It's nice~!!
can i use enable or visible property of a Tab?

This GUIDE Addition is absolutely incredible!

Igor Sankin

Sweet - nice and simple!

Amazing!! Really good work and simple to use. Thanks

Is there a possibility to use something like:
set(handles.tabManager.TabA02, 'Enable', 'off');
to disable specific tabs?

I get following error:
There is no Enable property on the Tab class.

Thank you

I am surprised how could MATHWORKS ignore such a basic feature in GUIDE. Thanks for sharing.

xen

This one is amazing!
Hopefully mathworks offers offical support.

Excellent work

Lico

Grant

Hi Lico, I've updated the example to show how to select a tab from code.
tabMan = handles.tabManager;
tabMan.Handles.TabA.SelectedTab = tabMan.Handles.TabA02Supplementary;

Lico

Hi, Grant,
Thanks for your excellent job. It really helps me a lot.
There is one small question about tab manager. Is it possible to switch tab by command not by mouse click? For example, I have 3 tabs, TabA1, TabA2, and TabA3, and I would like to automatically switch to TabA2 after completing some data plotting.

Thanks.

Grant

Hi zijing zelan,
You can show an image in the example figure (i.e. TabManagerExample) by adding the following code to the TabManagerExample_OpeningFcn.

img = imread('c:\temp\the_image.png');
image(img, 'Parent', handles.axes1);

Hi Grant,

I just want to ask how to plot a picture on an axes of a particular panel.

Thanks

Grant

Unfortunately, Matlab doesn't support setting size, color etc on tabs (apart from via undocumented java calls).

Y G

Can one change the size, color and fonts on the tabs?

Inés

I have a look at your TabManager .It seems the tool that I missed that MatLab provide in order to manage the tab panels through the guide.
Thank you for sharing it with us

Inés

All working now. The problem was between chair and the keyboard. Thanks so much to Grant for helping me out on this. This is exactly what I was looking for.

Grant

Hi Amit - Are you simply running an unmodified copy of TabManagerExample in Matlab 2015a? That should work fine. I've just tested this with Matlab 2015a. Contact me (developit at gmail.com) and I'll see if we can sort this out.

Hi Grant - I am looking for a tool exactly like this where I can combine all my different figure into one tabbed UI.

When I try your example file it does not seems to work for me.I am getting this error:

Error using handle.handle/get
Invalid or deleted object.
Error in TabManager (line 80)
panelTag = get(hPanel,'Tag');

I tried to make my own example like you have explained here http://stackoverflow.com/questions/11084565/how-do-i-create-a-tabbed-gui-in-matlab. But that didnt work either.

I am using Matlab2015a. Your help is appreciated.

Sean

Updates

1.6.0.0

Tab Order of children now maintained (was reversed).
Nested tabs supported (Thanks Timon)
TabManagerExample updated to show both changes.

1.5.0.0

The background colour of a placeholder panel is now copied to its corresponding uitab.

1.4.0.0

Changed the example (TabManagerExample.m) to show how to add a SelectionChangedFcn to the tab group so that a program can be notified when a user selects a tab.

1.3.0.0

A descriptive error message is now generated if a pane representing a tab is a child of the main pane (or another "tab" pane).

1.2.0.0

Modified the tab manager example to demonstrate how to select a tab from code and added a note to the TabManager class to describe how to do this.

1.1.0.0

typo in description

1.1.0.0

Added note regarding the sorting of pane tag names prior to tab creation that can be used to control the order of tabs.

MATLAB Release Compatibility
Created with R2014b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags
gui