Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
how call a GUI2 from a GUI1?

Subject: how call a GUI2 from a GUI1?

From: Camille Couzi

Date: 12 Aug, 2010 21:50:18

Message: 1 of 3

Hi matlabers,

I have a little problem with my GUI. I need to call a 2nd GUI from my first GUI. For that, I have a pushbutton "push_for_GUI2" in my GUI1, and then setted a callback for this pushbutton:
set (h.push_for_GUI2,'callback', ({@Open_GUI2,h}))
which I have defined after:

function Open_GUI2(hObject,eventdata,h)
h = guidata(hObject);
h.fig_GUI2=figure('parent',h.fig,'units','normalized','position', [.1 .3 .1 .1],...
    'name','Pelicanos Viewer','numbertitle','off');
 guidata(hObject, h);

("fig" is the figure of my first GUI).

The problem is that when I do that, I get an error message:
??? Error using ==> figure
An object of class figure, can not be a child of class figure.

How do I define my GUI2?

Thanks a lot for your help.
Camille.

Subject: how call a GUI2 from a GUI1?

From: Camille Couzi

Date: 12 Aug, 2010 22:08:05

Message: 2 of 3

"Camille Couzi" <camillecouzi@yahoo.fr> wrote in message <i41qaq$fk0$1@fred.mathworks.com>...
> Hi matlabers,
>
> I have a little problem with my GUI. I need to call a 2nd GUI from my first GUI. For that, I have a pushbutton "push_for_GUI2" in my GUI1, and then setted a callback for this pushbutton:
> set (h.push_for_GUI2,'callback', ({@Open_GUI2,h}))
> which I have defined after:
>
> function Open_GUI2(hObject,eventdata,h)
> h = guidata(hObject);
> h.fig_GUI2=figure('parent',h.fig,'units','normalized','position', [.1 .3 .1 .1],...
> 'name','Pelicanos Viewer','numbertitle','off');
> guidata(hObject, h);
>
> ("fig" is the figure of my first GUI).
>
> The problem is that when I do that, I get an error message:
> ??? Error using ==> figure
> An object of class figure, can not be a child of class figure.
>
> How do I define my GUI2?
>
> Thanks a lot for your help.
> Camille.

Found the solution in
http://www.mathworks.com/matlabcentral/newsreader/view_thread/280033

Thanks! :-)

Subject: how call a GUI2 from a GUI1?

From: Walter Roberson

Date: 12 Aug, 2010 22:55:18

Message: 3 of 3

Camille Couzi wrote:
> Hi matlabers,
>
> I have a little problem with my GUI. I need to call a 2nd GUI from my
> first GUI. For that, I have a pushbutton "push_for_GUI2" in my GUI1, and
> then setted a callback for this pushbutton:
> set (h.push_for_GUI2,'callback', ({@Open_GUI2,h}))
> which I have defined after:
>
> function Open_GUI2(hObject,eventdata,h)
> h = guidata(hObject);
> h.fig_GUI2=figure('parent',h.fig,'units','normalized','position', [.1 .3
> .1 .1],...
> 'name','Pelicanos Viewer','numbertitle','off');
> guidata(hObject, h);
>
> ("fig" is the figure of my first GUI).
>
> The problem is that when I do that, I get an error message:
> ??? Error using ==> figure
> An object of class figure, can not be a child of class figure.
>
> How do I define my GUI2?

You read the error message and cross-reference to your code, and see that you
are indeed trying to create a figure() whose parent is an existing figure.
That isn't allowed, so Don't Do That.

Tags for this Thread

No tags are associated with this thread.

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.

Contact us