Question

I have several GUI's which I would like to combine into one "master" GUI where I could select all the GUI's in different tabs. Is there a way to do it, without building the GUI from scratch? Just to make it clear:
GUI 1 Data Loading
GUI 2 Data Preprocessing
GUI 3 Data Analysis
Master GUI=Should have 3 tabs with the same layout etc. like the existing GUI's

Update: I tried the GUI Layout Toolbox which can be used to create tabs. But how do I now include my already existing GUI's into each tab?

f = figure();
p = uiextras.TabPanel();
uicontrol( 'Parent', p);
uicontrol( 'Parent', p);
uicontrol( 'Parent', p);
p.TabNames = {'Data Loading', 'Data Preprocessing', 'Data Analysis'};
p.TabSize = 100;

Update 2: Are there any other options to combine multiple GUI's?

Was it helpful?

Solution

IMHO, this pretty much depends on the implementation of the individual guis. If all GUIs make use of guidata and properties of the parent figure (of which there will be only one after the combination), this can quickly become impossible or at least messy without reworking all GUIs.

Another possibility would be to dock the figures into one desktop-group. This way each individual GUI would be kept isolated and doesn't need changes in its implementation. See e.g.

http://www.mathworks.nl/matlabcentral/fileexchange/18106-manage-and-dock-figures-into-group

for an example on how to dock figures into one desktop-group.

EDIT:

A quick&dirty example:

function dockTest()

    GROUPNAME = 'MyGUIs';
    desktop = com.mathworks.mde.desk.MLDesktop.getInstance();
    group = desktop.addGroup(GROUPNAME);
    desktop.showGroup(GROUPNAME,1);

    % create some dummy-figures:
    for i=1:2
        figureList(i) = figure('name', ['GUI ', num2str(i)],...
                               'numbertitle','off');
    end

    % dock figures in list:
    for i=1:numel(figureList)
        f = figureList(i);
        jf = get(handle(f), 'JavaFrame');
        jf.setGroupName(GROUPNAME);
        set(f, 'WindowStyle', 'docked');
    end

end

You should be able to simply make figureList (and maybe GROUPNAMEas well) be an argument to this function, hence passing it all figure-handles you want to dock into a group.

You don't need a toolbox for this.

I guess I should note that this is all based on undocumented features. I usually play around with this sort of things by making heavy use of methodsview on the individual java objects involved.

OTHER TIPS

Try the GUI Layout Toolbox from the File Exchange, it allows tabbed GUIs, which are not supported out of the box in MATLAB. There will probably be some re-writing of your existing GUIs to make them work with the GUI Layout Toolbox used for the main GUI, but hopefully this should be minimal.

One way to combine several GUI is to manipulate their visibility with an extra GUI.

  • create a main GUI with 3 buttons
  • in the opening function OpeningFcn, call your 3 gui and save their handles in the workspace with
STATE(1) = dataLoading; 
STATE(2) = dataProcessing; 
STATE(3) = dataAnalyzing;
assignin('base', 'STATE', STATE);

%make the first one visible
set(STATE(1),'Visible','on'); 
set(STATE(2),'Visible','off'); 
set(STATE(3),'Visible','off');     
  • in pushbutton_Callback, retrieve STATE and set a visibility property
STATE  = evalin('base', 'STATE');
set(STATE(1),'Visible','off'); 
set(STATE(3),'Visible','off'); 
set(STATE(2),'Visible','on'); 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top