3

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?

C.Colden
  • 627
  • 1
  • 8
  • 28
  • That's why I said there may be a little bit of re-writing/interfacing your existing GUIs to the new/main GUI. Essentially your existing GUIs should become children (I think) of each tab. – am304 Oct 04 '13 at 14:09
  • Could you give me an example? I am not sure how to implement this. – C.Colden Oct 04 '13 at 14:14
  • This is from the help of the `TabPanel` class: `f = figure();` `p = uiextras.TabPanel( 'Parent', f, 'Padding', 5 );` `uicontrol( 'Style', 'frame', 'Parent', p, 'Background', 'r' );` `uicontrol( 'Style', 'frame', 'Parent', p, 'Background', 'b' );` `uicontrol( 'Style', 'frame', 'Parent', p, 'Background', 'g' );` `p.TabNames = {'Red', 'Blue', 'Green'};` `p.SelectedChild = 2;` You can then add further `uicontrol` and other stuff that is in your existing GUIs. – am304 Oct 04 '13 at 14:55
  • How would you suggest to add a button to a certain tab? You can't add it as a parent, since this is not allowed. Any workaround? – C.Colden Oct 04 '13 at 15:33
  • 1
    Have a look at the example shown in http://blogs.mathworks.com/pick/2010/06/18/gui-layout-part-7/. The tabs are panels, you need to add boxes inside the panels before adding `uicontrol` objects such as buttons. If you download and install the toolbox, it has fairly extensive documentation. – am304 Oct 08 '13 at 12:33

3 Answers3

3

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.

sebastian
  • 9,526
  • 26
  • 54
  • I like the idea of docking the gui's together. Is there an easy way (without dealing with another toolbox) to dock 2 gui's together. From what I understand it will look like they're "magnetic", so stick to each other, right? – C.Colden Oct 08 '13 at 11:53
  • Is there a way just to adjust the pop-up gui position? Since this solution requires figures and not gui's... – C.Colden Oct 08 '13 at 13:44
2

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.

am304
  • 13,758
  • 2
  • 22
  • 40
  • Thank you for the link for this toolbox. It offers great features, however does not allow to combine the GUI's. Or did you saw a possibility? The GUI's are pretty complex, so to do them new is not a very efficient option. – C.Colden Oct 04 '13 at 11:07
2

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'); 
marsei
  • 7,691
  • 3
  • 32
  • 41