8
votes

I've created a small GUI to manipulate data and recently I decided to move the database to a MySQL server. I created a Java program to bring the data back and forth and I started to notice the delay when access servers abroad.

When you run scripts through the command window Matlab displays a "busy" text in the lower left corner but not when I'm running GUIs.

So how do I know if Matlab is busy when using GUIs?

Thanks in advance.

Edit: Quick example.

I run in the command window (or a script test.m)

for i = 1:100000
  a = i+i;
  disp(a);
end

The status bar says "Busy".

When I create a GUI, with the button "Click me" that executes the same exact script. The busy sign on the status bar does not appear.

Why is this and what can I do about it? I want to be able to see if my GUI is busy or not.

6
Rather than relying on the busy sign in the main IDE, could you not implement some sort of wait bar or print your own progress message to the command prompt. Both of these ideas are dicussed here.Chris

6 Answers

3
votes

You should be able to modify the status bar message of the main MATLAB window using the submission statusbar from Yair Altman on the MathWorks File Exchange. He discusses how it works in a post on his blog "Undocumented Matlab".

With this utility, you should be able to put up a "Busy..." message even when MATLAB doesn't do it automatically. Your code for the "Click me" button callback would probably look something like this:

...
statusbar(0, 'Busy...');  %# Set the status message
test;                     %# Run your function/script
statusbar(0, '');         %# Clear the status message
...
4
votes

It says so in the status bar of the main window!

EDIT:
So the answer is no, right now there is no way to (easily) say if matlab is busy doing something other than a command line job.

2
votes

You could add a static text on the GUI itself and set its text to 'Busy'/'Idle' before/after your calculations are done, if making the GUI more user-friendly is the concern.

2
votes

Probably what you are looking for:

Enter any arbritary code into the command line.

e.g. somthing like

asdfasdfasdfasdf

If the GUI routine is still running, then it will display busy, until the GUi function has ended. Only then it can start to execute asdfasdfasdfasdf.

If the Gui is already finished, then it will execute asdfasdfasdfasdf instantaneously and display the according error message.

Earlier all Matlabs displayed also the busy message, when beeing executing a Gui-started function. Since 2012 this seems no longer to be the case.

0
votes

Add a static text box to your GUI. In your calculate icon callback, write this:

set(handle.text,'string','busy')
pause(0.1)
.
.
.
// Your code
.
.
.
pause(0.1)
set(handle.text,'string','done')
0
votes

This thread over at MathWorks says it can be done using the File Exchange entry CmdWinTool. If you download that file, you can use it to find out if MATLAB is busy with CmdWinTool('isBusy'). Note that CmdWinTool takes advantage of undocumented features in MATLAB's use of Java, so MathWorks is unlikely to support it.