I'm trying to make a GUI in matlab which looks similar to matlab's preferences form. That is: I want some kind of contol on the left which, when activated, loads a number of controls on the right.
My idea was to make a figure for each "tab" page and then load this figure when required and show it inside the main figure. I like really like the idea of different figures because this keeps the code behind the separate tabs (which is quite a lot) nicely separated.
The question now is: how do I show this "child" figure (fully functional) inside the main figure?
"Ruben de Bruin" <oud.papier@inter.nl.net> wrote in message <f7poa2$l7k$1@fred.mathworks.com>...
> I'm trying to make a GUI in matlab which looks similar to matlab's preferences form. That is: I want some kind of contol on the left which, when activated, loads a number of controls on the right.
>
> My idea was to make a figure for each "tab" page and then load this figure when required and show it inside the main figure. I like really like the idea of different figures because this keeps the code behind the separate tabs (which is quite a lot) nicely separated.
>
> The question now is: how do I show this "child" figure (fully functional) inside the main figure?
>
> thanks in advance!
I've tried a few different methods to do what you're describing... my favorite option is to have the callback of each tab delete the existing uicontrols and create those corresponding to that tab (this option is pretty fast and avoids having tons of hidden uicontrols loaded at all times). The downside is you need to write the callback as a function (ie by typing out uicontrol commands) so you cant use guide to layout the controls...
But to do something more like you're describing, check out the copyobj function. You could do something like have the tab callback open a figure that contains the controls you want to add (set the new figure's visible to off so you cant see it) then copy the controls from that figure to your tab panel, then close the source figure. I've never tried this method, so I can't really comment on it. The typical problem with any method that creates/deletes objects is in managing their handles and making sure other functions don't try to set/get properties of uicontrols that don't always exist.
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central.
Read the complete Disclaimer prior to use.