Thread Subject: GUI: hangs up

Subject: GUI: hangs up

From: Yogesh

Date: 8 Oct, 2007 16:15:53

Message: 1 of 6

Hello!
I have a problem with a GUI running in MATLAB 7.0. It hangs
when I execute minimization routine through it. The
description of GUI is as follows.

The GUI is created using GUIDE for least squares
minimization code. The code determines model parameter by
minimizing the difference between observed and model
predicted values. The GUI preprocesses the data, set
minimization solver options and plots end results . The top
level figure contains 6 uipanels which in turn contains
several uicontrol objects like editable text, push button,
etc and menubar. To simulate TAB like environment each
uipanel is made visible when corresponding panel name is
selected in menubar and other visible status of other
uipanels is set to 0.

Snapshots of this GUI can be seen at
http://www.mip.ups-tlse.fr/~parte/MATLAB_PROBLEM/GUI_Details.pdf

The problem is when I start running the minimization solver,
which performs number of iterations, the GUI figure doesn't
show uicontrol object properly (See the last snapshot) and I
get message that GUI is not responding.

After every iteration the solver updates the listbox and
progress bar. There is a STOP button to stop solver on user
demand. When iterations are being carried out, the GUI
doesn't respond immediately. However if iterations are
interrupted using CNTRL+C at command prompt, all uicontrol
objects are visible and one can see that listbox panel and
progress bar is updated till latest iterations. (See
snapshot on page 2)

I tried using "drawnow" function at the end of iteration but
   the problem persists. What could be the reason behind
this? Is it possible to overcome this behaviour and provide
clean GUI?

The datasets being used are small, about 600 observations
and model used is simple which has 15 parameters and
involves inversion of 5X5 matrix (carried out usig "/"
operator).
The laptop on which code is run has 2GB RAM,
Intel Core 2 duo, T7200, 2GHZ processor.
Java VM Version: Java 1.4.2_04 with Sun Microsystems Inc.
YP
---

Subject: GUI: hangs up

From: Fangjun Jiang

Date: 17 Oct, 2007 15:02:33

Message: 2 of 6

I had this problem in various versions of Matlab in many
occations. Now I know how to deal with it.

I have an educated guess for the cause of the problem. In
the code, after the user giving inputs through GUI, if
there are intensive calculations need to be executed, the
GUI windows usually freeze. I did a test. I had a dialog
window created by questdlg() which has two buttons ("Yes"
and "No"). If user clicks "Yes", the program do some
intensive calculation. If user clicks "No", the program is
ended. When I run the test, if I click "No", all seem
nomal. If I click "Yes", the dialog window got stuck. The
CPU usage in the task manager flares up but the CPU is not
running my intensive calculation because if it does, there
shall be some display in the Matlab command window. It
took a while for the computer to get out of the freezed
window and start to run the intensive calculation.

So the problem is that the computer doesn't have enough
time to refresh the GUI. Sometimes, I started to click
other windows of other application such as IE, Word, etc.
which makes it worse. In some cases, I can't wait any
longer so I just kill the Matlab application.

There are suggestions that adding a "drawnow" statement
after the GUI function (questdlg() statement in my case)
could solve the problem. I tried but it didn't work well.

My solution is to add a pause(0.2) statement instead of
drawnow statement. It works every time.

Subject: GUI: hangs up

From: Fangjun Jiang

Date: 17 Oct, 2007 15:02:42

Message: 3 of 6

I had this problem in various versions of Matlab in many
occations. Now I know how to deal with it.

I have an educated guess for the cause of the problem. In
the code, after the user giving inputs through GUI, if
there are intensive calculations need to be executed, the
GUI windows usually freeze. I did a test. I had a dialog
window created by questdlg() which has two buttons ("Yes"
and "No"). If user clicks "Yes", the program do some
intensive calculation. If user clicks "No", the program is
ended. When I run the test, if I click "No", all seem
nomal. If I click "Yes", the dialog window got stuck. The
CPU usage in the task manager flares up but the CPU is not
running my intensive calculation because if it does, there
shall be some display in the Matlab command window. It
took a while for the computer to get out of the freezed
window and start to run the intensive calculation.

So the problem is that the computer doesn't have enough
time to refresh the GUI. Sometimes, I started to click
other windows of other application such as IE, Word, etc.
which makes it worse. In some cases, I can't wait any
longer so I just kill the Matlab application.

There are suggestions that adding a "drawnow" statement
after the GUI function (questdlg() statement in my case)
could solve the problem. I tried but it didn't work well.

My solution is to add a pause(0.2) statement instead of
drawnow statement. It works every time.

Subject: GUI: hangs up

From: Yogesh

Date: 24 Oct, 2007 14:15:44

Message: 4 of 6

Hello!
Thank you for your reply and suggestion. But even after
using pause command the problem persists.
YP

Subject: GUI: hangs up

From: Jerome Briot

Date: 24 Oct, 2007 14:28:14

Message: 5 of 6

Yogesh a écrit :

> I tried using "drawnow" function at the end of iteration but
> the problem persists.

Hi,

did you try with REFRESH ?

Jérôme

Subject: GUI: hangs up

From: Fangjun Jiang

Date: 25 Oct, 2007 15:45:47

Message: 6 of 6

I am pretty confident that the cause of the GUI hangs up
is the one I explained before.

You seem to have a quite complex GUI. Can you step through
your code to pinpoint the place that causes the hangs up?
You must know the place where you give the last input to
your GUI and your code starts to run but the GUI hangs up.
Put a pause statement there. You have to strike a key then
to let the code continue. See if the GUI still hangs up. I
predict you won't have GUI hangs up when you step through
your code.

My experience is, to make the pause(0.2) work, it has to
be added after every place where there is a need to
refresh the GUI and there is intensive calculations
following. Examples are like, questdlg(), inputdlg(), etc.
For those dialog window, the window has to disappear after
the user input. Adding a pause(0.2) statement after the
questdlg() or inputdlg() statement prevents GUI hangs up
in many of my cases. drawnow() or refresh() works
sometimes but not as robust as pause().

If pause(0.2) is not enough, try to increase the time,
maybe pause(0.5).

"Yogesh " <yogesh.parte.nospam@mathworks.com> wrote in
message <ffnk2g$qmi$1@fred.mathworks.com>...
> Hello!
> Thank you for your reply and suggestion. But even after
> using pause command the problem persists.
> YP

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
guide Yogesh 14 Oct, 2007 14:48:26
gui Yogesh 8 Oct, 2007 12:20:22
rssFeed for this Thread
 

MATLAB Central Terms of Use

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 Terms prior to use.

Contact us at files@mathworks.com