Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

closing a figure with push button

404 views
Skip to first unread message

Torsten Imig

unread,
Apr 24, 2002, 8:12:44 AM4/24/02
to
hi,
i want to close a figure (a GUI) with a pushbutton.
what i have to write in the callback ?

thanks,
torsten


John D'Errico

unread,
Apr 24, 2002, 9:12:57 AM4/24/02
to
In article <aa66g5$geo$1...@rs04.hrz.uni-essen.de>, "Torsten Imig"
<tor...@imig.de> wrote:

> i want to close a figure (a GUI) with a pushbutton.
> what i have to write in the callback ?

The esiest thing to put in the callback is 'exit'.
'quit' will also work quite well.

You did not say you want matlab to remain running
after the figure closes.

I suppose if you just want to close the figure,
you could try something like 'delete(gcbf)' as
a callback.

Usually when I close a figure I want to return
something. That takes more work of course.

John

--

David

unread,
Apr 24, 2002, 11:11:20 AM4/24/02
to
Torsten Imig wrote:
>
>
> hi,
> i want to close a figure (a GUI) with a pushbutton.
> what i have to write in the callback ?
>
If the button is on the figure that you want closed, then that figure
will be your current figure when the button is pressed.
Therefore, 'close(gcf)' will work for you. If you want all figures to
close, 'close all' will work. If you want some other figure to close,
it gets more complicated. The figure handle must be passed to the
close command somehow. If you use a global variable 'fig_handle',
then close(fig_handle) will work, but there are more elegant ways.
Good luck.


David

J.O. Entzinger

unread,
Apr 24, 2002, 12:31:29 PM4/24/02
to
>>i want to close a figure (a GUI) with a pushbutton.
>>what i have to write in the callback ?

> The esiest thing to put in the callback is 'exit'.
> 'quit' will also work quite well.
>
> You did not say you want matlab to remain running
> after the figure closes.


When putting "quit cancel" in a file called finish.m Matlab will not
quit using "quit" of "exit", but all other matlab windows will be closed :-)


> I suppose if you just want to close the figure,
> you could try something like 'delete(gcbf)' as
> a callback.


you can use close(figure(1)) if the figure is made by the command
"figure" or you can make a handler to the figure when making is
(H=figure;) and later say "close(H)" to close it.

J.O. Entzinger


Liz

unread,
Mar 16, 2012, 3:08:18 PM3/16/12
to
I am trying to do a similar thing (close a figure with a push button) and keep getting this message in the Command Window:

Error while evaluating uicontrol Callback

I know it is the error in the 'quit' callback because that's all I've done to the file.

I have tried quit, delete, close functions, is there something I need to preface them with?

"J.O. Entzinger" <J.O.En...@student.utwente.nl> wrote in message <3CC6DDE1...@student.utwente.nl>...

ImageAnalyst

unread,
Mar 16, 2012, 4:21:18 PM3/16/12
to
On Mar 16, 3:08 pm, "Liz " <erh...@gmail.com> wrote:
> I am trying to do a similar thing (close a figure with a push button) and keep getting this message in the Command Window:
>
> Error while evaluating uicontrol Callback
>
> I know it is the error in the 'quit' callback because that's all I've done to the file.
>
> I have tried quit, delete, close functions, is there something I need to preface them with?
-------------------------------------------------------------------------------

Well we don't know what you tried because you didn't share your code.
Basically you do
delete(handles.figMainWindow); % uses handles structure like GUIDE
does.
or
delete(handleToYourFigure);
From the partial info you gave it looks like you're trying to delete
or create a control on a figure (like a button, table, axes, etc.)
rather than the figure itself. Please post all the code in your quit
callback.
0 new messages