How to create tabbed GUI in MatLab?

I want to create a tabbed GUI in which the first tab is for reading input, then the input is displayed in the GUI. The user should be able to select data from the graphical user interface, and then be indicated as input to the algorithm. Also, the user can select the options for algortihm in another tab. On the third tab, the user can see the received graphs.

How to create tabbed GUI in MatLab programmatically or using GUIDE?

+6
source share
2 answers

Here is a simple example of using the semi-documented UITAB function to create tabs:

function tabbedGUI() %# create tabbed GUI hFig = figure('Menubar','none'); s = warning('off', 'MATLAB:uitabgroup:OldVersion'); hTabGroup = uitabgroup('Parent',hFig); warning(s); hTabs(1) = uitab('Parent',hTabGroup, 'Title','Data'); hTabs(2) = uitab('Parent',hTabGroup, 'Title','Params'); hTabs(3) = uitab('Parent',hTabGroup, 'Title','Plot'); set(hTabGroup, 'SelectedTab',hTabs(1)); %# populate tabs with UI components uicontrol('Style','pushbutton', 'String','Load data...', ... 'Parent',hTabs(1), 'Callback',@loadButtonCallback); uicontrol('Style','popupmenu', 'String','r|g|b', ... 'Parent',hTabs(2), 'Callback',@popupCallback); hAx = axes('Parent',hTabs(3)); hLine = plot(NaN, NaN, 'Parent',hAx, 'Color','r'); %# button callback function loadButtonCallback(src,evt) %# load data [fName,pName] = uigetfile('*.mat', 'Load data'); if pName == 0, return; end data = load(fullfile(pName,fName), '-mat', 'X'); %# plot set(hLine, 'XData',data.X(:,1), 'YData',data.X(:,2)); %# swithc to plot tab set(hTabGroup, 'SelectedTab',hTabs(3)); drawnow end %# drop-down menu callback function popupCallback(src,evt) %# update plot color val = get(src,'Value'); clr = {'r' 'g' 'b'}; set(hLine, 'Color',clr{val}) %# swithc to plot tab set(hTabGroup, 'SelectedTab',hTabs(3)); drawnow end end 

tab1tab2tab3

+10
source

You can also create tabs from the generated GUIDE GUI using the utility available from the File File File that I wrote.

Usage is quite simple:

  • Create a panel with a tag set to Tab? Where? any letter or number (e.g. TabA). This main panel should be empty and determines the size and location of the tab group (uitabgroup).
  • Create additional panels with a tag name that begins with the name of the main panel. All other controls should be added to these panels.
  • In the xxx_OpeningFcn function created on the screen, add the following:

    handles.tabManager = TabManager (hObject);

The location of the additional panels does not matter, but it is usually easier to edit the graphical interface if they are in the same place as the main panel. You can edit panels even if they are superimposed by cycling through the panels using the Send Back command from the Guide pop-up menu.

Tab group place holder Main tab Additional tab GUI Result

0
source

Source: https://habr.com/ru/post/918369/


All Articles