From: Camille Couzi on
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.
From: Camille Couzi on
"Camille Couzi" <camillecouzi(a)yahoo.fr> wrote in message <i41qaq$fk0$1(a)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! :-)
From: Walter Roberson on
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.