Thread Subject: GUI: I do not want to see a GUI that was set invisible

Subject: GUI: I do not want to see a GUI that was set invisible

From: Wolfgang Stamm

Date: 7 Jan, 2008 16:22:02

Message: 1 of 5

Hello MATLAB community,

I have a GUI (from GUIDE) whith uiwait in the opening
function. Then I have a "run" button inside the GUI. When
the user presses this button, I do the following things:

- Set the 'visible' property of the figure to 'off'. It does
what I want: the GUI disappears.
- Do some calculus which takes a long time. Save the result
in the run button callback to handles.output.
- uiresume
- The GUI's output function is executed. Here handles.output
is written to varargout{1} and the GUI is finally deleted.

It all works fine, but one thing I do not like: After the
call of uiresume, when MATLAB does some stuff in the
background and the figure is not deleted yet because the
output function has not been called yet, the GUI flashes for
about quarter of a second. It's no big deal, but it is just
something which
1) Surprises me. 'visible' was set to 'off', so who makes it
visible again. I tried to debug the stuff which MATLAB does
between uiresume and the output function, but didn't
understand quite much.
2) Is nasty. When I say 'off', I mean 'off', OK?
3) Doesn't look professional to any user. People don't trust
in programs which mess up your screen, and if it's only for
a wink. If the look and feel is poor, the user will believe
your calculus is messy too.

Can you confirm the described behaviour? If yes, don't you
think it's annoying (as I do)? If your answer is again yes,
did you ever try to get around it?

I'm using R2007b.

Subject: GUI: I do not want to see a GUI that was set invisible

From: matt dash

Date: 7 Jan, 2008 17:23:02

Message: 2 of 5

"Wolfgang Stamm" <wolfgREMang.staMOVEmm@luINVALIDk.de> wrote
in message <fltjja$la9$1@fred.mathworks.com>...
> Hello MATLAB community,
>
> I have a GUI (from GUIDE) whith uiwait in the opening
> function. Then I have a "run" button inside the GUI. When
> the user presses this button, I do the following things:
>
> - Set the 'visible' property of the figure to 'off'. It does
> what I want: the GUI disappears.
> - Do some calculus which takes a long time. Save the result
> in the run button callback to handles.output.
> - uiresume
> - The GUI's output function is executed. Here handles.output
> is written to varargout{1} and the GUI is finally deleted.
>
> It all works fine, but one thing I do not like: After the
> call of uiresume, when MATLAB does some stuff in the
> background and the figure is not deleted yet because the
> output function has not been called yet, the GUI flashes for
> about quarter of a second. It's no big deal, but it is just
> something which
> 1) Surprises me. 'visible' was set to 'off', so who makes it
> visible again. I tried to debug the stuff which MATLAB does
> between uiresume and the output function, but didn't
> understand quite much.
> 2) Is nasty. When I say 'off', I mean 'off', OK?
> 3) Doesn't look professional to any user. People don't trust
> in programs which mess up your screen, and if it's only for
> a wink. If the look and feel is poor, the user will believe
> your calculus is messy too.
>
> Can you confirm the described behaviour? If yes, don't you
> think it's annoying (as I do)? If your answer is again yes,
> did you ever try to get around it?
>
> I'm using R2007b.

It's been a while, but if I recall, guide gui's always turn
on visibility after running the opening function. It sounds
like you don't really need the uiwait in the opening
function and you can just let the opening function finish
and then have the run button's callback hide the figure and
do whatever it needs to do.

Subject: GUI: I do not want to see a GUI that was set invisible

From: Wolfgang Stamm

Date: 8 Jan, 2008 10:00:21

Message: 3 of 5

> It's been a while, but if I recall, guide gui's always turn
> on visibility after running the opening function. It sounds
> like you don't really need the uiwait in the opening
> function and you can just let the opening function finish
> and then have the run button's callback hide the figure and
> do whatever it needs to do.
>
Thanks for your answer, Matt. When I omit the uiwait in the
opening function, the output function is executed right
after the opening function. Then I don't see how I could
return something to the GUI's caller function, which has
been calculated in the run callback. I need the output
function to execute after the run callback. Hence, I need
uiwait.

Subject: GUI: I do not want to see a GUI that was set invisible

From: Wolfgang Stamm

Date: 8 Jan, 2008 11:11:02

Message: 4 of 5

Matt, you gave me a good hint: When I turn off the figure's
visibility in GUIDE and turn it on manually in the opening
function just before the uiwait statement, I get the desired
behavior. I think it has to do with the value of gui_Visible
on line 164 of gui_mainfcn. Anyway, I don't want to wade
through all gui_mainfcn. It works now.

Subject: GUI: I do not want to see a GUI that was set invisible

From: matt dash

Date: 9 Jan, 2008 19:05:04

Message: 5 of 5

"Wolfgang Stamm" <wolfgREMang.staMOVEmm@luINVALIDk.de> wrote
in message <flvlo6$7nk$1@fred.mathworks.com>...
> Matt, you gave me a good hint: When I turn off the figure's
> visibility in GUIDE and turn it on manually in the opening
> function just before the uiwait statement, I get the desired
> behavior. I think it has to do with the value of gui_Visible
> on line 164 of gui_mainfcn. Anyway, I don't want to wade
> through all gui_mainfcn. It works now.


Sounds like you've got it figured out. For posterity: I
believe that before the opening function GUIDE gui's run the
layout function, which is empty be default, and so it simply
replaces it with a function that opens the fig file and
turns its visiblity to on (and also does some annoying
resizing in certain cases). I dont know the exact order it
does these things because it must open the file before the
opening function, but resize it after the opening function.

But anyway, if you want to override any of this, you can
manually add a layout function that opens the fig file and
does whatever visibility/positioning you want. (most people
try to put this in the opening function and thats why it
doesnt work there.. it belongs in the layout function)This
requires some editing in the "do not edit" section of the
m-file... something like this:

gui_State = struct('gui_Name', mfilename, ...
    'gui_Singleton', gui_Singleton, ...
    'gui_OpeningFcn', @blah_OpeningFcn, ...
    'gui_OutputFcn', @blah_OutputFcn, ...
    'gui_LayoutFcn', @blah_Layout , ...
    'gui_Callback', []);

%later, in body of m file:
function h=blah_Layout(varargin)
h=openfig('blah.fig','new','invisible'); %for an invisible gui.

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
full size gui Kevin 12 May, 2010 13:56:05
rssFeed for this Thread

Contact us at files@mathworks.com