Thread Subject: [GUI] showing one figure inside an other

Subject: [GUI] showing one figure inside an other

From: Ruben de Bruin

Date: 20 Jul, 2007 07:30:10

Message: 1 of 2

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!

Subject: [GUI] showing one figure inside an other

From: matt dash

Date: 20 Jul, 2007 15:32:50

Message: 2 of 2

"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.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
gui tabs matt dash 20 Jul, 2007 11:35:06
gui figure parent tab panel Ruben de Bruin 20 Jul, 2007 03:35:03
rssFeed for this Thread

Public Submission Policy

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.

Contact us at files@mathworks.com